An OCaml toplevel (terminal) embedded online (Try OCaml version)


Javascript is required!

This web page embeds some small programs written in javascript. This should work in any recent web browser, supporting javascript (and it should not be disabled).

Voir aussi

I recommend the following, more modern and comprehensive tools!

  • is a good little OCaml editor (with the code on the left, the output of its execution on the right), developed by a CPGE MP* student in 2020) ;

  • is another good environment to use the basic OCaml system online, without installing anything!It’s done by OCamlPro and the « official » solution ;

  • Learn-OCaml is a heavier and more complete environment. Not sure if it works entirely offline.

Voir aussi

Locally use an OCaml editor and interpreter? It is possible on this site! Without having to install anything!

BetterOCaml is a simple OCaml console and editor, but one that works online without the need for a server that computes your code behind: everything is interpreted in javascript in your browser!I host a local copy here: BetterOCaml. It is also on

The terminal

Try OCaml

OCaml is a strongly typed functional language. It is concise and fast, enabling you to improve your coding efficiency while producing code with higher quality.

Type lesson 1 to start the tutorial.
(click on the code to insert)
lesson 1 Simple Expressions
lesson 2 Imperative Programming
lesson 3 Functions
lesson 4 Pattern Matching
lesson 5 Syntax Traps
lesson 19 The Graphics module
lesson 20 New Features in 3.12.1

Enter / Return Submit code
Up / DownCycle through history
Shift + EnterMultiline edition
lesson 1 Move to lesson 1
step 1 Move to step 1 of the current lesson
lessons () See available lessons
steps () See available steps in the current lesson
OCaml powered :)

Voir aussi

Simple OCaml Toplevel

The page ocaml.en.html embeds a simpler OCaml terminal, less up-to date, but which has the advantage of being easier to include (a single Javascript file, _static/toplevel.js, and no CSS tweaks).


The Javascript scripts used on my web pages are now stored on this git repository : lbesson/web-sphinx-scripts, on


  • OCaml is © and ® Inria;

  • Try OCaml is © and ® OCaml Pro.