Js_of_ocaml

A compiler from OCaml bytecode to Javascript.

It makes OCaml programs that run on Web browsers. It is easy to install as it works with an existing installation of OCaml, with no need to recompile any library. It comes with bindings for a large part of the browser APIs.

This web-based OCaml toplevel is compiled using Js_of_ocaml.

Command

Enter/Return Submit code
Ctrl + Enter Newline
Up / Down Browse history
Ctrl + l Clear display
Ctrl + k Reset toplevel
Tab Indent code

Try to execute samples

Graphics: PingPong Graphics: Draw chars Graphics: Draw Reactive dom Mutually recursive module Mutually recursive function Overview

See the generated javascript code

(function(globalThis)
  {"use strict";
   var runtime=globalThis.jsoo_runtime;
   function caml_call2(f,a0,a1)
    {return f.length == 2?f(a0,a1):runtime.caml_call_gen(f,[a0,a1])}
   var
    global_data=runtime.caml_get_global_data(),
    Stdlib_Format=global_data[654],
    Toploop=global_data[20473],
    cst_print_unit=global_data[20518],
    cst=global_data[20519];
   function _a_(fmt,param){return caml_call2(Stdlib_Format[13],fmt,cst)}
   return caml_call2(Toploop[2],cst_print_unit,_a_)});