OCamlFormat review
A configurable OCaml formatter with Dune, editor, RPC, and library integrations.
Reviewed by iTechGuides Editors · Editorial team · Updated Oct 2026
OCamlFormat is an open-source automatic formatter for OCaml projects, with particular fit for teams using Dune. It formats OCaml source files as well as comments, docstrings, and OCaml code blocks inside comments. Developers can run it from the command line, apply formatting in place, or check whether files are formatted without changing them. Project-level behavior is controlled through .ocamlformat files, making the tool suitable for repositories that need shared formatting rules rather than ad hoc local preferences.
Configuration and repository control are central to the product. Formatting profiles and options allow projects to define how code should be presented, while .ocamlformat-ignore files exclude selected files from formatting. Dune integration through dune fmt connects formatting with an existing OCaml build workflow. Editor plugins extend the same formatting capability into development environments, and ocamlformat-rpc supports formatting requests through an RPC server. These options make OCamlFormat adaptable across command-line, build, editor, and tooling workflows without limiting use to a single interface.
The programmatic library API is useful when formatting needs to be embedded into another OCaml tool or development process. The MIT License and open-source distribution also suit projects that want to inspect, integrate, and adapt the formatter within their own workflows. OCamlFormat is a strong choice for OCaml teams seeking consistent formatting with explicit project rules and Dune support. Projects looking for a multi-language formatter or a broader suite of code analysis features should choose a different category tool, since OCamlFormat is narrowly focused on formatting OCaml code.
OCamlFormat pros and cons
- Where it wins
- Formats code, comments, docstrings, and code blocks in comments
- Supports .ocamlformat profiles and .ocamlformat-ignore rules
- Offers Dune, RPC, editor-plugin, and programmatic API integration
- Where it doesn't
- Focused on OCaml rather than multiple programming languages
- Requires project configuration for tailored formatting profiles
- Its feature set centers on formatting rather than broader code quality checks
OCamlFormat fact sheet, pricing and score →
Advertiser disclosure: iTechGuides is reader-supported. Vendors can pay for top positions in our rankings and for a place on other products' pages, and we may earn a commission when you click some links. Bought places stand at the number bought; this page and our disclosure say so. Paying vendors may get a fuller, more detailed review from our editors, and that review can change their score. How we rank.
Last updated · How we research and update