Need help with gen_js_api?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

150 Stars 25 Forks MIT License 517 Commits 12 Opened issues


Easy OCaml bindings for Javascript libraries

Services available


Need anything else?

Contributors list

genjsapi: easy OCaml bindings for JavaScript libraries

Build Status


genjsapi aims at simplifying the creation of OCaml bindings for JavaScript libraries. It must currently be used with the jsofocaml 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).

genjsapi 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.

genjsapi can be used in two complementary ways:


The repository contains some examples of OCaml bindings to JavaScript libraries created with genjsapi:


Related projects

  • jsofocaml: The compiler and runtime system on which genjsapi relies. (Note: genjsapi doesn't depend on jsofocaml'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.

  • ReScript: Another compiler from OCaml to JavaScript, featuring the genType ppx for generating TS / Flow types and runtime converters.


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

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

See see Changelog

Contact: [email protected]


  • Alain Frisch
  • Sebastien Briais

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.