What is the ML file format?
.ml is the standard source file extension for the OCaml programming language, a statically typed functional language with object-oriented and imperative features developed at INRIA, Paris. The extension derives from ML (Meta Language), the family of languages from which OCaml descends.
Each .ml file defines one OCaml module, automatically named after the file with its first letter capitalized - parser.ml becomes the module Parser. The companion .mli interface file declares what the module exposes publicly, acting similarly to a C header file.
Source files contain sequences of OCaml declarations: let bindings, type definitions, module and functor definitions, exception declarations, and class definitions. A let () = ... expression at the top level serves as the program entry point by convention.
Files are compiled by ocamlc to bytecode or by ocamlopt to native machine code. The Dune build system and the opam package manager are the standard project management tools. OCaml 5.x (2022 onward) introduced effect handlers and multicore parallelism, adding new syntax not accepted by older compilers.
The .ml extension is also occasionally seen for Standard ML files, though that community typically uses .sml instead. The dominant use is OCaml, which reached version 5.3 in 2025.
Security & safety
RISK: LOWPlain text source code; no execution risk when opened in a text editor. Risk only when compiled and run - review code before compiling untrusted .ml files.
Format details
in a nutshell- Standard ML (SML) source file - Some Standard ML implementations accept .ml but .sml is the conventional extension.
- Reason/ReasonML source file - Facebook's Reason syntax for OCaml occasionally coexists with .ml files in the same project.
Programs that open ML files
Technical details
deep spec| Language family | ML (Meta Language) - functional, statically typed |
| Module naming | Each `.ml` file = one module; filename capitalized becomes module name |
| Interface companion | `.mli` file declares the module's public signature (analogous to a header) |
| Bytecode compiler | `ocamlc` → `.cmo` object file / `.cma` library output |
| Native compiler | `ocamlopt` → `.cmx` / `.cmxa` / native binary |
| Build system | Dune (standard modern); OMake, Makefile (legacy) |
| Encoding | UTF-8; full Unicode supported since OCaml 4.14 (legacy codebases: ASCII) |
| Notable syntax additions | OCaml 4.02 (attributes), 4.08 (binding operators), 5.x (effects, domains) |
| Type system | Hindley-Milner with GADTs, polymorphic variants, and first-class modules |
| MIME type | `text/x-ocaml` |
| Standard library module | `Stdlib` (renamed from `Pervasives` in OCaml 4.07) |
| Associated OS | Linux, macOS, Windows, FreeBSD |
| Released | 1973 (ML); OCaml .ml usage since 1996 |
| Latest version | OCaml 5.3 (2025) |
| Open standard | Yes · royalty-free |
| Specification | v2.ocaml.org |
ML conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about ML files.