gitwtfhub

wtf is ocamlformat?

bbatsov/ocamlformat — explained in plain English

Analysis updated 2026-08-15 · repo last pushed 2026-03-31

Audience · developerComplexity · 2/5MaintainedLicenseSetup · moderate

TL;DR

An opinionated auto-formatter for OCaml code that enforces consistent spacing, indentation, and line breaks so teams never argue about style in code reviews.

Mindmap

mindmap
  root((repo))
    What it does
      Auto-formats OCaml code
      Cleans up comments
      Tidy doc strings
    Profiles and config
      Standard default
      Jane Street style
      Internal style
      Custom config file
    Integration
      Dune build system
      Server mode for editors
      Part of OCaml Platform
    Tech stack
      OCaml
      Dune
      RPC server
    Audience
      OCaml developers
      Solo hobbyists
      Large engineering teams
    Backing
      Jane Street
      Tarides

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Format an entire OCaml project with a single Dune command.

REASON 2

Set up a custom formatting profile so code matches your team's preferred style.

REASON 3

Integrate with a code editor via server mode to format files on the fly.

REASON 4

Standardize code style across a team to eliminate formatting debates in code reviews.

What's in the stack?

OCamlDuneRPC

How it stacks up

bbatsov/ocamlformat000madz000/rfid-attendance00kaku/gallery-slider-block
LanguageTypeScriptJavaScript
Last pushed2026-03-312024-07-222021-05-19
MaintenanceMaintainedDormantDormant
Setup difficultymoderateeasyeasy
Complexity2/52/52/5
Audiencedeveloperdevelopergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · moderate Time to first run · 30min

Requires an OCaml toolchain and optionally the Dune build system to be set up in your project.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

Wtf does this do

ocamlformat is a tool that automatically tidies up OCaml source code so developers don't have to argue about how it should look. You run it on a file, and it reformats the code to follow a consistent style, spacing, indentation, line breaks, and so on. This saves teams from debating formatting choices in code reviews and keeps codebases visually consistent. The tool ships with opinionated defaults, meaning it makes formatting decisions for you out of the box. But if you disagree with those choices, you can create a small configuration file in your project to tweak things. There are also three preset "profiles" to choose from: the standard default, one matching the tool's own internal style, and one following conventions from Jane Street, a major OCaml company. Beyond regular code, it can also clean up comments and documentation strings, including code examples embedded in comments. The primary audience is anyone writing OCaml, from individual hobbyists to large engineering teams. For a solo developer, it saves time you'd otherwise spend manually aligning code. For a team, it eliminates a whole category of code review arguments, nobody needs to comment on indentation or spacing because the formatter handles it. It's also designed to integrate into standard OCaml workflows, so if your project uses the Dune build system, formatting your entire project is a single command. One notable design choice is that the tool doesn't just format code but also offers a server mode (called RPC) that other tools can talk to. This means code editors and IDEs can format files on the fly without launching the tool separately each time. The project is officially part of the OCaml Platform, which is the recommended toolset for the language, and it has backing from organizations including Jane Street and Tarides.

Yoink these prompts

Prompt 1
I have an OCaml project using Dune. Help me add ocamlformat to it so running 'dune fmt' formats every file automatically.
Prompt 2
I disagree with some ocamlformat defaults. Show me how to create an .ocamlformat config file that switches to the Jane Street profile and tweaks a few spacing options.
Prompt 3
I want my VS Code or Emacs editor to format OCaml files on save using ocamlformat's RPC server mode. Walk me through the setup.
Prompt 4
Explain the differences between ocamlformat's standard, internal, and Jane Street profiles so I can pick the right one for my team.
Prompt 5
Help me configure ocamlformat to also reformat code examples inside doc comments in my OCaml project.

Frequently asked questions

wtf is ocamlformat?

An opinionated auto-formatter for OCaml code that enforces consistent spacing, indentation, and line breaks so teams never argue about style in code reviews.

Is ocamlformat actively maintained?

Maintained — commit in last 6 months (last push 2026-03-31).

What license does ocamlformat use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is ocamlformat to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is ocamlformat for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.