FREEDOM251

Freedom251 › Code Transpilers

js_of_ocaml

Free plan APILinuxWeb

Visit js_of_ocaml Alternatives Pricing

js_of_ocaml's own site

What js_of_ocaml is

js_of_ocaml compiles OCaml bytecode into JavaScript for running programs in browsers and Node.js. It works with an existing OCaml installation, so libraries do not need to be recompiled. Dune supports the compiler directly, using separate compilation during development and whole-program compilation for release builds. The release approach can remove unused code across the program and optimize between modules to produce smaller, faster output.

Its library provides a typed interface between OCaml and JavaScript, including PPX syntax for JavaScript properties, methods, constructors, and objects. Browser bindings cover APIs such as the DOM, Fetch, WebSockets, WebGL, workers, and typed arrays. Optional packages provide Lwt support, TyXML, JSON derivation, and an OCaml toplevel that runs in a browser.

Documented runtime targets include Node.js 18 or later, QuickJS-NG, and modern browsers implementing ECMAScript 2020. The listed compiler requirements are OCaml 4.13 to 5.5, Dune 3.20 or later, and Menhir. The project is free and open source, with installation through opam. Its documentation also identifies limits: most of the Sys module is unsupported, Graphics is partially supported, extra libraries such as Thread are generally unsupported, and tail calls are not optimized in general.

Who it suits

js_of_ocaml suits OCaml developers who want to run bytecode programs in browsers or Node.js and use browser APIs through OCaml bindings. It is also relevant to teams using Dune who want separate development builds and whole-program release compilation.

What it does well

  • Works with existing OCaml libraries without recompiling them.
  • Dune supports development and release compilation workflows natively.
  • Typed interface and PPX syntax support JavaScript interoperability.
  • Browser bindings cover DOM, Fetch, WebSockets, WebGL, workers, and typed arrays.
  • Optional packages include Lwt, TyXML, JSON derivation, and a browser toplevel.
  • Free, open source, and installable through opam.

What to know first

  • Most of the Sys module is unsupported.
  • Extra OCaml libraries such as Thread are generally unsupported.
  • Graphics support is partial.
  • Tail calls are not optimized in general.

Limits

Most of the Sys module is unsupported, Graphics is partially supported, extra libraries such as Thread are generally unsupported, and tail calls are not optimized in general. The facts state no free-plan quotas or usage limits.

Plans

PlanBilled and limitsPrice
js_of_ocamlNo paid plans or usage limits stated on the pages reviewedFree

As ocsigen.org lists them, read 9 Oct 2026. The maker's own page has the final word.

Getting started

  1. Install the compiler and related packages through opam.
  2. Use an OCaml installation meeting the documented compiler requirements: OCaml 4.13 to 5.5, Dune 3.20 or later, and Menhir.
  3. Use Dune's native js_of_ocaml support for separate development compilation or whole-program release compilation.
  4. Run generated JavaScript in Node.js 18 or later, QuickJS-NG, or a modern ES2020 browser.

Verdict

Choose js_of_ocaml if you want to compile OCaml bytecode for browser or Node.js use, especially when Dune and its browser bindings fit your workflow. Check the stated library and runtime limitations if your program relies on Sys, Thread, Graphics, or general tail-call optimization.

Questions

How much does js_of_ocaml cost?

The listed plan is free. No paid plans or usage limits are stated.

Is js_of_ocaml open source?

Yes. The repository lists GPL-2.0-or-later and LGPL-2.1-or-later with the OCaml linking exception.

Where can generated JavaScript run?

Documented targets include Node.js 18 or later, QuickJS-NG, and modern browsers implementing ECMAScript 2020.

How do I install it?

The compiler and related packages are installable through opam, the OCaml package manager.

What are the main compatibility limits?

Most of the Sys module is unsupported, Graphics is partially supported, and extra libraries such as Thread are generally unsupported. Tail calls are not optimized in general.

How can users get support?

The project directs users to GitHub issues for problems or questions and asks them to include version details and, when possible, a minimal reproducible example.

Facts from js_of_ocaml's own pages

Async integration
The optional js_of_ocaml-lwt package provides Lwt support and bindings including DOM events, XMLHttpRequest, and JavaScript promises. · ocsigen.org, 9 Oct 2026
Browser APIs
The base library includes bindings for browser APIs such as DOM, Fetch, WebSockets, WebGL, workers, and typed arrays. · ocsigen.org, 9 Oct 2026
Browser bindings
The project includes bindings for a large part of browser APIs. · ocsigen.org, 9 Oct 2026
Browser support
Generated JavaScript supports modern browsers that implement ECMAScript 2020, including Chrome 80+, Firefox 74+, Safari 13.4+, and Edge 80+. · ocsigen.org, 9 Oct 2026
Build integration
Dune supports js_of_ocaml natively and selects separate compilation in dev and whole-program compilation in release builds. · ocsigen.org, 9 Oct 2026
Installation
The compiler and related packages are installable through opam, the OCaml package manager. · ocsigen.org, 9 Oct 2026
JavaScript interop
Its library provides a typed interface for bridging differences between OCaml and JavaScript values. · ocsigen.org, 9 Oct 2026
JavaScript interoperability
The library provides a typed interface for bridging OCaml and JavaScript values, with PPX syntax for JavaScript properties, methods, constructors, and objects. · ocsigen.org, 9 Oct 2026
Libraries
The distribution includes packages for Lwt support, TyXML, JSON derivation, and running an OCaml toplevel in the browser. · ocsigen.org, 9 Oct 2026
License
The repository lists GPL-2.0-or-later and LGPL-2.1-or-later with the OCaml linking exception as its licenses. · github.com, 9 Oct 2026
Limits
Most of the Sys module is unsupported, extra OCaml libraries such as Thread are generally unsupported, and tail calls are not optimized in general. · ocsigen.org, 9 Oct 2026
Node support
The installation guide lists Node.js 18 or later as a supported environment. · ocsigen.org, 9 Oct 2026
No recompiling libraries
It works with an existing OCaml installation and does not require recompiling libraries. · ocsigen.org, 9 Oct 2026
Optimization
Whole-program compilation performs global dead-code elimination and cross-module optimizations to produce smaller and faster output. · ocsigen.org, 9 Oct 2026
Performance
The project says its benchmarks show generated programs typically run faster than with the OCaml bytecode interpreter. · ocsigen.org, 9 Oct 2026
Purpose
Js_of_ocaml compiles OCaml bytecode programs to JavaScript so they can run in browsers and Node.js. · ocsigen.org, 9 Oct 2026
Requirements
The documented compiler requirements include OCaml 4.13 to 5.5, Dune 3.20 or later, and Menhir. · ocsigen.org, 9 Oct 2026
Runtime targets
Generated JavaScript is documented to work with Node.js 18 or later, modern ES2020 browsers, and QuickJS-NG. · ocsigen.org, 9 Oct 2026
Security and compliance
The project pages reviewed do not state a security certification or compliance claim. · ocsigen.org, 9 Oct 2026
Support
The project asks users to report problems or questions through GitHub issues and include version details and a minimal reproducible example when possible. · ocsigen.org, 9 Oct 2026
Support channel
The contribution guide directs users to open a GitHub issue to report problems or ask questions. · ocsigen.org, 9 Oct 2026
Supported OCaml libraries
Most of the OCaml standard library is supported, while most of the Sys module is not supported and Graphics is partially supported. · github.com, 9 Oct 2026

Where js_of_ocaml stands on Freedom251

Look at these too