EVERYTHING XIAOMI
Get listed

js_of_ocaml

js_of_ocaml compiles OCaml bytecode programs into JavaScript for use in browsers and Node.js.

Place
#7 of 28
Score
6.5
js_of_ocaml's website

What js_of_ocaml is

js_of_ocaml compiles OCaml bytecode programs into JavaScript for use in browsers and Node.js. It works with an existing OCaml installation without requiring libraries to be recompiled, and Dune supports it natively, using separate compilation in development and whole-program compilation for release builds. The whole-program mode performs global dead-code elimination and cross-module optimization. Its library provides a typed interface between OCaml and JavaScript values, along with browser API bindings such as the DOM, Fetch, WebSockets, WebGL, workers, and typed arrays. Optional packages add Lwt support, TyXML, JSON derivation, and an OCaml toplevel in the browser. Documented runtime targets include Node.js 18 or later, QuickJS-NG, and modern ES2020 browsers. Requirements include OCaml 4.13 to 5.5, Dune 3.20 or later, and Menhir; installation is through opam. The project is free and open source, with GPL-2.0-or-later and LGPL-2.1-or-later licenses with the OCaml linking exception. Most of the standard library is supported, but most of the Sys module is not.

Good

  • Works without recompiling existing OCaml libraries.
  • Dune supports development and release compilation modes.
  • Includes bindings for a broad set of browser APIs.
  • Free and open source, with packages available through opam.

Watch out

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

Who it suits

It suits OCaml developers who want to target JavaScript environments while using browser bindings and typed OCaml-to-JavaScript interoperability.

Verdict

js_of_ocaml offers a route from OCaml bytecode to JavaScript, with Dune integration and browser bindings. Check its runtime and library limits against the application you plan to build.

Plans and prices

From js_of_ocaml's own pricing page, checked 9 Oct 2026.

All about pricing
PlanPriceWhat it gives you
js_of_ocamlFreeNo paid plans or usage limits stated on the pages reviewed

The facts

Each one read from js_of_ocaml's own pages, with the date it was checked.

What it does

Async integration
The optional js_of_ocaml-lwt package provides Lwt support and bindings including DOM events, XMLHttpRequest, and JavaScript promises.checked 9 Oct 2026
Build integration
Dune supports js_of_ocaml natively and selects separate compilation in dev and whole-program compilation in release builds.checked 9 Oct 2026
Installation
The compiler and related packages are installable through opam, the OCaml package manager.checked 9 Oct 2026
JavaScript interop
Its library provides a typed interface for bridging differences between OCaml and JavaScript values.checked 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.checked 9 Oct 2026
Libraries
The distribution includes packages for Lwt support, TyXML, JSON derivation, and running an OCaml toplevel in the browser.checked 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.checked 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.checked 9 Oct 2026
Node support
The installation guide lists Node.js 18 or later as a supported environment.checked 9 Oct 2026
No recompiling libraries
It works with an existing OCaml installation and does not require recompiling libraries.checked 9 Oct 2026
Optimization
Whole-program compilation performs global dead-code elimination and cross-module optimizations to produce smaller and faster output.checked 9 Oct 2026
Performance
The project says its benchmarks show generated programs typically run faster than with the OCaml bytecode interpreter.checked 9 Oct 2026
Purpose
Js_of_ocaml compiles OCaml bytecode programs to JavaScript so they can run in browsers and Node.js.checked 9 Oct 2026
Requirements
The documented compiler requirements include OCaml 4.13 to 5.5, Dune 3.20 or later, and Menhir.checked 9 Oct 2026
Runtime targets
Generated JavaScript is documented to work with Node.js 18 or later, modern ES2020 browsers, and QuickJS-NG.checked 9 Oct 2026
Security and compliance
The project pages reviewed do not state a security certification or compliance claim.checked 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.checked 9 Oct 2026
Support channel
The contribution guide directs users to open a GitHub issue to report problems or ask questions.checked 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.checked 9 Oct 2026

Where it runs

Browser APIs
The base library includes bindings for browser APIs such as DOM, Fetch, WebSockets, WebGL, workers, and typed arrays.checked 9 Oct 2026
Browser bindings
The project includes bindings for a large part of browser APIs.checked 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+.checked 9 Oct 2026

Alternatives to js_of_ocaml

All alternatives
  1. 1

    JSweet

    Free planOpen sourceAndroidiOSWebAPI
    7.7Free plan
  2. 2SWC logo

    SWC

    Free planAndroidWebAPILinux
    7.1Free plan
  3. 3

    Transcrypt

    Free planWebLinuxmacOSSelf-hosted
    6.7Free plan
  4. 4
    6.6Free plan
  5. 5

    Google Web Toolkit

    Free planWebExtensionLinuxmacOS
    6.5Free plan
  6. 6

    Haxelib

    Free planAPILinuxmacOSWindows
    6.5Free plan