Skip to content
Easy OCaml bindings for Javascript libraries
OCaml Other
  1. OCaml 98.3%
  2. Other 1.7%
Branch: master
Clone or download
nojb Merge pull request #94 from facelesspanda/typo
[typo] correct wrong 'apply_arr' to 'apply'
Latest commit 7bd36e7 Sep 2, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples examples dont depend on js_of_ocaml Aug 7, 2019
ppx-driver small tuning Aug 1, 2019
ppx-lib move files around Aug 1, 2019
ppx-standalone fix install section Aug 1, 2019
.gitignore cleanup gitignore Aug 1, 2019
.ocp-indent Add ocp-indent config. Mar 30, 2015 Update Jun 9, 2016 Doc. Apr 24, 2015 more doc Aug 1, 2019
LICENSE Doc. Apr 22, 2015 Rename iterate_properties into iter_properties. May 28, 2015
Makefile fix makefile Aug 1, 2019 Typo Sep 8, 2016 Doc. Apr 24, 2015 Fix for OCaml 4.05.0 and prepare for next release. Jul 13, 2017 TODO. Jun 1, 2015 Add default case for sums and unions. Jun 22, 2015 Use a greek letter for meta-variables. Jul 17, 2017
dune fix warnings Aug 1, 2019
dune-project add project name Aug 2, 2019
gen_js_api.opam need at least ocaml 4.08 Aug 8, 2019

gen_js_api: easy OCaml bindings for Javascript libraries


gen_js_api aims at simplifying the creation of OCaml bindings for Javascript libraries. It must currently be used with the js_of_ocaml compiler, although other ways to run OCaml code "against" Javascript might be supported later with the same binding definitions (for instance, Bucklescript, or direct embedding of a JS engine in a native OCaml application).

gen_js_api is based on the following ideas:

  • Authors of bindings write OCaml signatures for Javascript libraries and the tool generates the actual binding code with a combination of implicit conventions and explicit annotations.

  • The generated binding code takes care of translating values between OCaml and Javascript and of dealing with Javascript calling conventions.

  • All syntactic processing is done by authors of bindings: the client code is normal OCaml code and does not depend on custom syntax nor on JS-specific types.

gen_js_api can be used in two complementary ways:


The repository contains some examples of OCaml bindings to Javascript libraries created with gen_js_api:


Related projects

  • js_of_ocaml: The compiler and runtime system on which gen_js_api relies. (Note: gen_js_api doesn't depend on js_of_ocaml's OCaml library, nor on its language extension.)

  • goji: A DSL to describe OCaml bindings for JavaScript libraries.

  • DefinitelyMaybeTyped: A project to parse DefinitelyTyped interfaces and produce OCaml interfaces.

  • Bucklescript: Another compiler from OCaml to Javascript.


gen_js_api has been created by LexiFi for porting a web application from Javascript to OCaml. The tool has been used in production since 2015.

This gen_js_api package is licensed by LexiFi under the terms of the MIT license.

See see Changelog



  • Alain Frisch
  • Sebastien Briais
You can’t perform that action at this time.