Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. OCaml
  3. ocamlformat

ocamlformat

MITOCaml0.29.0

An auto-formatter for OCaml code with customizable profiles and comment formatting.

GitHubGitHub
716 stars220 forks0 contributors

What is ocamlformat?

ocamlformat is an automated code formatter for OCaml that enforces consistent code style across projects. It is part of the OCaml Platform, providing opinionated yet flexible formatting to eliminate stylistic debates and help teams maintain clean, readable codebases.

Target Audience

OCaml developers and teams seeking to standardize code formatting in their projects, particularly those using the OCaml Platform toolset.

Value Proposition

Developers choose ocamlformat for its seamless integration with the OCaml ecosystem, customizable profiles like 'janestreet', and features such as comment formatting and an RPC server for editor tooling.

Overview

Auto-formatter for OCaml code

Use Cases

Best For

  • Enforcing consistent code style across OCaml projects to eliminate formatting debates.
  • Integrating automated formatting into CI/CD pipelines for OCaml codebases.
  • Teams adopting the OCaml Platform and needing a standardized formatter.
  • Formatting comments, docstrings, and code blocks within comments in OCaml files.
  • Customizing formatting rules via .ocamlformat configuration files to match specific coding standards.
  • Using the RPC server for editor integrations to format OCaml code on-the-fly.

Not Ideal For

  • Projects with legacy OCaml codebases that rely on non-standard, manually enforced formatting conventions which ocamlformat's opinionated defaults might disrupt.
  • Environments requiring immediate, zero-configuration formatting without any setup, such as quick scripts or one-off files where creating .ocamlformat files is impractical.
  • Teams that prioritize fine-grained control over every stylistic detail and find automated formaters too restrictive for their specific coding guidelines.

Pros & Cons

Pros

Predefined Formatting Profiles

Includes profiles like 'janestreet' for industry-standard styles, allowing teams to quickly adopt consistent formatting without starting from scratch, as mentioned in the README.

Highly Customizable Configuration

Fully configurable via .ocamlformat files, enabling precise tuning of formatting rules to match project-specific coding standards, as highlighted in the features.

Comprehensive Comment Formatting

Formats comments, docstrings, and code blocks within comments, ensuring all code aspects are styled consistently, a feature explicitly noted in the README.

RPC Server for Integration

Provides an RPC interface for easy integration with editors and tools, facilitating on-the-fly formatting and enhancing development workflow, as stated in the key features.

Cons

Configuration Overhead

Requires creating and managing .ocamlformat files with version pinning (e.g., 'version = 0.29.0'), which can be cumbersome for simple projects or users new to OCaml tooling.

Dependency on OCaml Ecosystem

Relies on OCaml and opam for installation and usage, making it less accessible for mixed-language projects or environments without these specific dependencies.

Potential Breaking Changes

The need to specify version in configuration suggests updates may introduce breaking changes, requiring manual adjustments and compatibility checks, as implied by the version pinning recommendation.

Frequently Asked Questions

Quick Stats

Stars716
Forks220
Contributors0
Open Issues122
Last commit17 days ago
CreatedSince 2017

Tags

#developer-tools#build-tools#code-formatter#rpc-server#code-style#auto-formatting#ocaml

Built With

O
OPAM
d
dune
O
OCaml

Included in

OCaml3.1k
Auto-fetched 1 day ago

Related Projects

merlinmerlin

Context sensitive completion for OCaml in Vim and Emacs

Stars1,688
Forks251
Last commit6 days ago
utoputop

Universal toplevel for OCaml

Stars921
Forks121
Last commit1 month ago
ocaml-lspocaml-lsp

OCaml Language Server Protocol implementation

Stars897
Forks155
Last commit1 day ago
ctypesctypes

Library for binding to C libraries using pure OCaml

Stars409
Forks102
Last commit6 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub