.ML

ML File

ML / OCaml Source Code File
Ask a question
QUICK ANSWER

A .ml file is an OCaml source code file - plain text containing functional, imperative, or object-oriented code written in the OCaml language. Open it with any text editor or VS Code with the OCaml Platform extension. To compile and run it, install the OCaml toolchain from ocaml.org and use ocamlopt or the dune build system.

Developer: Robin Milner (ML, 1973); OCaml by INRIA / Caml Team (1996) Category: Developer Files Open standard MIME: text/x-ocaml
OPENS ON Windows macOS Linux
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Jul 3, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

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: LOW

Plain 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
FULL NAMEML / OCaml Source Code Fileaka OCaml implementation file, Meta Language source file
DEVELOPERRobin Milner (ML, 1973); OCaml by INRIA / Caml Team (1996)since 1973 (ML); OCaml .ml usage since 1996
MIME TYPEtext/x-ocaml
TYPEplain text source code
STANDARDOpen · royalty-free
This extension is also used by…
  • 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

Windows3 apps
Microsoft Visual Studio Freemium F# / OCaml support via extensions; not a primary OCaml IDE on Windows.
NotePad++ text editor Open-source Open file directly; syntax highlighting via OCaml UDL plugin.
Visual Studio Code + OCaml Platform extension Open-source Install OCaml LSP via opam, then open the .ml file - syntax highlighting, type-on-hover, go-to-definition.
macOS3 apps
TextMate Open-source Open file; OCaml bundle provides syntax highlighting.
Visual Studio Code + OCaml Platform extension Open-source Install OCaml via Homebrew (brew install ocaml opam), then open .ml file in VS Code.
Caml (INRIA Caml site) Open-source Legacy INRIA Caml site redirects to OCaml.org; use ocaml.org toolchain instead.
Linux3 apps
Vim Open-source Open file; install vim-ocaml plugin for syntax and merlin integration.
OCaml (compiler + toolchain) Open-source ocamlopt foo.ml -o foo to compile; utop REPL for interactive use.
Emacs + Tuareg mode Open-source M-x tuareg-mode; classic OCaml development environment.

Technical details

deep spec
Language familyML (Meta Language) - functional, statically typed
Module namingEach `.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 systemDune (standard modern); OMake, Makefile (legacy)
EncodingUTF-8; full Unicode supported since OCaml 4.14 (legacy codebases: ASCII)
Notable syntax additionsOCaml 4.02 (attributes), 4.08 (binding operators), 5.x (effects, domains)
Type systemHindley-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 OSLinux, macOS, Windows, FreeBSD
Released1973 (ML); OCaml .ml usage since 1996
Latest versionOCaml 5.3 (2025)
Open standardYes · royalty-free
Specificationv2.ocaml.org

ML conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with ML files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about ML files.

Frequently asked questions

What program opens a .ml file?
Any text editor (VS Code, Notepad++, Vim, Emacs). To compile and run, install the OCaml toolchain from ocaml.org.
Is .ml an ML or OCaml file?
Primarily OCaml - the .ml extension is the standard OCaml implementation file. Standard ML files conventionally use .sml, but some SML projects use .ml too.
How do I compile a .ml file?
Install OCaml, then: ocamlopt foo.ml -o foo (native binary) or ocamlc foo.ml -o foo.byte (bytecode). For multi-file projects, use the dune build system.
Can I open a .ml file in Visual Studio?
Yes, but VS Code with the OCaml Platform extension is the recommended modern choice on all platforms.

References

1OCaml official siteocaml.org
2Real World OCaml - Files, Modules, and Programsdev.realworldocaml.org

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.JPGJPEG Image
4.PARTPartial Download File
5.MDMarkdown Document
6.RPMSGRestricted Permission Message
7.BINCD/DVD Disc Image (BIN/CUE)
8.DATProgram Data File (generic)
9.EXEWindows Executable (Portable Executable)
10.DBSQLite Database File

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z