# \#ocamlformat

**URL:** https://discuss.ocaml.org/tag/ocamlformat/105.md

[Latest](https://discuss.ocaml.org/latest.md) · [Categories](https://discuss.ocaml.org/categories.md) · [Tags](https://discuss.ocaml.org/tags.md)

---

## [How to disable ocamlformat from formatting record into one line?](https://discuss.ocaml.org/t/how-to-disable-ocamlformat-from-formatting-record-into-one-line/18168)

<div class="topic-metadata">

**Author:** [@allonsyeet](https://discuss.ocaml.org/u/allonsyeet)\
**Replies:** 2\
**Last updated:** [May 25, 2026, 8:22am UTC](https://discuss.ocaml.org/t/how-to-disable-ocamlformat-from-formatting-record-into-one-line/18168 "2026-05-25T08:22:23Z")

</div>

I have a record that I’ve formatted like so Ok { x = s.x +. (s.v \*. p.dt); v = s.v +. (-.p.k \*. s.x \*. p.dt) } When I run ocamlformat on this I get this Ok { x = s.x +. (s.v \*. p.dt); v = s.v +. (-.p.k \*. s.x \*. …

---

## [Confusion about code structuring, dune, ocamlformat, ocamldoc (overall workflow)](https://discuss.ocaml.org/t/confusion-about-code-structuring-dune-ocamlformat-ocamldoc-overall-workflow/17726)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 1\
**Last updated:** [January 23, 2026, 10:47am UTC](https://discuss.ocaml.org/t/confusion-about-code-structuring-dune-ocamlformat-ocamldoc-overall-workflow/17726 "2026-01-23T10:47:01Z")

</div>

I am still (somewhat) new to OCaml and I struggle with the overall workflow of creating a project, organizing my code, documenting it, and automatically creating documentation. I would like to share my experiences here a…

---

## [OCamlformat for two latest stable releases?](https://discuss.ocaml.org/t/ocamlformat-for-two-latest-stable-releases/17275)

<div class="topic-metadata">

**Author:** [@Kakadu](https://discuss.ocaml.org/u/Kakadu)\
**Replies:** 4\
**Last updated:** [September 23, 2025, 3:17pm UTC](https://discuss.ocaml.org/t/ocamlformat-for-two-latest-stable-releases/17275 "2025-09-23T15:17:51Z")

</div>

Do we have an ocamlformat version that works both for 4.14.2 and 5.3? (It seems answer is no) Without it I have difficulties with testing my code on different compilers. Installing different versions of ocamlformat seem…

---

## [How to instruct ocamlformat to add a space between two let statements?](https://discuss.ocaml.org/t/how-to-instruct-ocamlformat-to-add-a-space-between-two-let-statements/17013)

<div class="topic-metadata">

**Author:** [@arielf212](https://discuss.ocaml.org/u/arielf212)\
**Replies:** 1\
**Last updated:** [July 26, 2025, 4:59pm UTC](https://discuss.ocaml.org/t/how-to-instruct-ocamlformat-to-add-a-space-between-two-let-statements/17013 "2025-07-26T16:59:21Z")

</div>

I have the following code: let add x y = x + y let print\_add x y = Printf.printf "%d + %d = %d\\n" x y @@ add x y let () = print\_add 1 2 ocamlformat removes the blank lines, e.g.: let add x y = x + y let print\_add x y…

---

## [Ocamlformat: Avoiding newline in recursive module declarations](https://discuss.ocaml.org/t/ocamlformat-avoiding-newline-in-recursive-module-declarations/16806)

<div class="topic-metadata">

**Author:** [@joelreymont](https://discuss.ocaml.org/u/joelreymont)\
**Replies:** 0\
**Last updated:** [June 13, 2025, 3:52pm UTC](https://discuss.ocaml.org/t/ocamlformat-avoiding-newline-in-recursive-module-declarations/16806 "2025-06-13T15:52:13Z")

</div>

Is there a way to have end = Memory\_region below? I can’t find a setting to accomplish this. module rec Memory\_region : sig type kind = S.Space.k \[@@deriving sexp\] type t = { id : id ; kind : kind ; si…

---

## [Ocamlformat: forcing a newline](https://discuss.ocaml.org/t/ocamlformat-forcing-a-newline/16757)

<div class="topic-metadata">

**Author:** [@joelreymont](https://discuss.ocaml.org/u/joelreymont)\
**Replies:** 2\
**Last updated:** [June 6, 2025, 1:04pm UTC](https://discuss.ocaml.org/t/ocamlformat-forcing-a-newline/16757 "2025-06-06T13:04:54Z")

</div>

Is there a way to force ocamlformat to always put a newline after let if followed by a record? That is, replace the current output let make ~mnemonic ~output = { mnemonic; output } with this let make ~mnemonic ~outpu…

---

## [Ocamlformat 0.27.0 reformatting code](https://discuss.ocaml.org/t/ocamlformat-0-27-0-reformatting-code/15761)

<div class="topic-metadata">

**Author:** [@orbitz](https://discuss.ocaml.org/u/orbitz)\
**Replies:** 1\
**Last updated:** [December 6, 2024, 3:13pm UTC](https://discuss.ocaml.org/t/ocamlformat-0-27-0-reformatting-code/15761 "2024-12-06T15:13:02Z")

</div>

I just upgraded from ocamlformat 0.26.2 to 0.27.0 and it is turning: // (\* path \*) Ret.text // (\* workflow\_idx \*) Ret.(option smallint) // (\* workspace \*) Ret.text into // (\* path \*) …

---

## [OCamlformat and GitHub actions](https://discuss.ocaml.org/t/ocamlformat-and-github-actions/15464)

<div class="topic-metadata">

**Author:** [@hannes](https://discuss.ocaml.org/u/hannes)\
**Replies:** 8\
**Last updated:** [October 21, 2024, 4:07pm UTC](https://discuss.ocaml.org/t/ocamlformat-and-github-actions/15464 "2024-10-21T16:07:42Z")

</div>

Dear everybody, a small announcement for those using OCamlformat in their projects: if you find the burden on external contributors very high, and always express “please run ocamlformat on your PR” – we’ve been in the s…

---

## [Experience with formatting a code base with topiary](https://discuss.ocaml.org/t/experience-with-formatting-a-code-base-with-topiary/14659)

<div class="topic-metadata">

**Author:** [@nojb](https://discuss.ocaml.org/u/nojb)\
**Replies:** 3\
**Last updated:** [May 19, 2024, 11:30am UTC](https://discuss.ocaml.org/t/experience-with-formatting-a-code-base-with-topiary/14659 "2024-05-19T11:30:36Z")

</div>

At LexiFi we are in the same boat: we have been using ocp-indent for ages, and continue to do so, and are happy with it. However, and mostly for the benefit of beginners and general user-friendliness of the codebase, we…

---

## [Should OCamlFormat Default Profile be Improved?](https://discuss.ocaml.org/t/should-ocamlformat-default-profile-be-improved/14645)

<div class="topic-metadata">

**Author:** [@sabine](https://discuss.ocaml.org/u/sabine)\
**Replies:** 11\
**Last updated:** [May 17, 2024, 6:05pm UTC](https://discuss.ocaml.org/t/should-ocamlformat-default-profile-be-improved/14645 "2024-05-17T18:05:28Z")

</div>

Hey everyone! On OCamlFormat, there’s a few open issues and pull requests relating to OCamlFormat’s default profile that aren’t progressing and where it is unclear whether they should be pursued or retired. For example…

---

## [How to compile ocamlformat? Obvious steps missing?](https://discuss.ocaml.org/t/how-to-compile-ocamlformat-obvious-steps-missing/13768)

<div class="topic-metadata">

**Author:** [@chshersh](https://discuss.ocaml.org/u/chshersh)\
**Replies:** 5\
**Last updated:** [January 4, 2024, 8:09pm UTC](https://discuss.ocaml.org/t/how-to-compile-ocamlformat-obvious-steps-missing/13768 "2024-01-04T20:09:01Z")

</div>

Hi everyone :wave: I’m trying to hack on ocamlformat. Unfortunately, the package doesn’t have instructions on how to build it. So I assume something default and obvious should work. After looking at the CI config, I tr…

---

## [Ocamlformat: unexpected 4x indent for multi-line arguments](https://discuss.ocaml.org/t/ocamlformat-unexpected-4x-indent-for-multi-line-arguments/13563)

<div class="topic-metadata">

**Author:** [@smolkaj](https://discuss.ocaml.org/u/smolkaj)\
**Replies:** 14\
**Last updated:** [December 6, 2023, 1:46pm UTC](https://discuss.ocaml.org/t/ocamlformat-unexpected-4x-indent-for-multi-line-arguments/13563 "2023-12-06T13:46:25Z")

</div>

I’ve been playing with ocamlformat and am mostly very happy – thanks for the great tool! – but I am running into one unexpected behavior that I have been unable to tame. Here is an example: Actual formatting (4x indenta…

---

## [Ocaml formatting in jupyter notebooks](https://discuss.ocaml.org/t/ocaml-formatting-in-jupyter-notebooks/13168)

<div class="topic-metadata">

**Author:** [@korbiniak](https://discuss.ocaml.org/u/korbiniak)\
**Replies:** 1\
**Last updated:** [October 5, 2023, 1:39pm UTC](https://discuss.ocaml.org/t/ocaml-formatting-in-jupyter-notebooks/13168 "2023-10-05T13:39:47Z")

</div>

Hey there, is there any easy way to run ocamlformat in the jupyter notebooks?

---

## [Ocamlformat option for aligning \`|\>\`?](https://discuss.ocaml.org/t/ocamlformat-option-for-aligning/11528)

<div class="topic-metadata">

**Author:** [@sanette](https://discuss.ocaml.org/u/sanette)\
**Replies:** 6\
**Last updated:** [February 28, 2023, 3:38pm UTC](https://discuss.ocaml.org/t/ocamlformat-option-for-aligning/11528 "2023-02-28T15:38:48Z")

</div>

I like to use the |\> operator for “post-modifying functions” to mimic a sort of imperative style, and hence the code is naturally formatted like this: let x = create a |\> modify\_by b |\> enhance\_with c …

---

## [Help for configuration of ocamlformat](https://discuss.ocaml.org/t/help-for-configuration-of-ocamlformat/10789)

<div class="topic-metadata">

**Author:** [@vzytoi](https://discuss.ocaml.org/u/vzytoi)\
**Replies:** 4\
**Last updated:** [November 28, 2022, 3:38pm UTC](https://discuss.ocaml.org/t/help-for-configuration-of-ocamlformat/10789 "2022-11-28T15:38:00Z")

</div>

Hey, I just installed ocamlformat because I’m studying in class with ocaml and I’m trying to configure the formatter such as the code looks like how I was used to format it. I have currently two point: - Is it possible…

---

## [Is there a tool to format ocamllex and menhir files?](https://discuss.ocaml.org/t/is-there-a-tool-to-format-ocamllex-and-menhir-files/3789)

<div class="topic-metadata">

**Author:** [@ale](https://discuss.ocaml.org/u/ale)\
**Replies:** 5\
**Last updated:** [October 21, 2022, 9:21pm UTC](https://discuss.ocaml.org/t/is-there-a-tool-to-format-ocamllex-and-menhir-files/3789 "2022-10-21T21:21:46Z")

</div>

I use ocamlformat extensively and it would be awesome to have a similar tool to format lexer and parser files as well. Is there any such tool?

---

## [Why was \`align-cases\` removed from ocamlformat?](https://discuss.ocaml.org/t/why-was-align-cases-removed-from-ocamlformat/10219)

<div class="topic-metadata">

**Author:** [@shonfeder](https://discuss.ocaml.org/u/shonfeder)\
**Replies:** 10\
**Last updated:** [July 26, 2022, 5:14am UTC](https://discuss.ocaml.org/t/why-was-align-cases-removed-from-ocamlformat/10219 "2022-07-26T05:14:05Z")

</div>

I much preferred formatting that aligned cases, and found it to be a really non-trivial gain in readability and accessibility. Suddenly, I find the option gone after updating, but I can’t find any explanation of why this…

---

## [\[ANN\] OCamlFormat Web Configurator](https://discuss.ocaml.org/t/ann-ocamlformat-web-configurator/10103)

<div class="topic-metadata">

**Author:** [@Khady](https://discuss.ocaml.org/u/Khady)\
**Replies:** 5\
**Last updated:** [July 15, 2022, 5:25am UTC](https://discuss.ocaml.org/t/ann-ocamlformat-web-configurator/10103 "2022-07-15T05:25:48Z")

</div>

It is my pleasure to share with you the ocamlformat configurator as a web page. Ocamlformat is a great tool that really makes editing code a more pleasant experience. It has a bunch of different built in profiles and ma…

---

## [\[ANN\] OCamlFormat 0.19.0](https://discuss.ocaml.org/t/ann-ocamlformat-0-19-0/8167)

<div class="topic-metadata">

**Author:** [@gpetiot](https://discuss.ocaml.org/u/gpetiot)\
**Replies:** 2\
**Last updated:** [July 21, 2021, 10:51am UTC](https://discuss.ocaml.org/t/ann-ocamlformat-0-19-0/8167 "2021-07-21T10:51:30Z")

</div>

We are happy to announce the release of OCamlFormat 0.19.0. OCamlformat is an auto-formatter for OCaml code, writing the parse tree and comments in a consistent style, so that you do not have to worry about formatting i…

---

## [\[ANN\] OCamlFormat 0.17.0](https://discuss.ocaml.org/t/ann-ocamlformat-0-17-0/7287)

<div class="topic-metadata">

**Author:** [@gpetiot](https://discuss.ocaml.org/u/gpetiot)\
**Replies:** 0\
**Last updated:** [February 16, 2021, 3:25pm UTC](https://discuss.ocaml.org/t/ann-ocamlformat-0-17-0/7287 "2021-02-16T15:25:14Z")

</div>

Hi all, On behalf of the OCamlFormat development team I am pleased to announce the release of ocamlformat.0.17.0 :tada:. OCamlformat is an auto-formatter for OCaml code, writing the parse tree and comments in a consist…

---

## [\[ANN\] OCamlformat 0.15.0](https://discuss.ocaml.org/t/ann-ocamlformat-0-15-0/6210)

<div class="topic-metadata">

**Author:** [@gpetiot](https://discuss.ocaml.org/u/gpetiot)\
**Replies:** 0\
**Last updated:** [August 7, 2020, 4:06pm UTC](https://discuss.ocaml.org/t/ann-ocamlformat-0-15-0/6210 "2020-08-07T16:06:02Z")

</div>

On behalf of the development team, I’d like to announce the release of ocamlformat version 0.15.0 :tada:. Here are the main highlights of this release: Support for OCaml 4.11 This means both that it compiles and runs u…

---

## [Using ocamlformat in a base-0.14 switch](https://discuss.ocaml.org/t/using-ocamlformat-in-a-base-0-14-switch/5963)

<div class="topic-metadata">

**Author:** [@MattWindsor91](https://discuss.ocaml.org/u/MattWindsor91)\
**Replies:** 2\
**Last updated:** [June 12, 2020, 8:33pm UTC](https://discuss.ocaml.org/t/using-ocamlformat-in-a-base-0-14-switch/5963 "2020-06-12T20:33:43Z")

</div>

(This is probably a specific instance of a more general question) As we know, the 0.14 release of Jane Street’s base ecosystem recently landed, and I’d like to try it out to see if it’s easy enough to upgrade my OCaml p…

---

## [\[ANN\] ocamlformat 0.14.2](https://discuss.ocaml.org/t/ann-ocamlformat-0-14-2/5754)

<div class="topic-metadata">

**Author:** [@gpetiot](https://discuss.ocaml.org/u/gpetiot)\
**Replies:** 0\
**Last updated:** [May 12, 2020, 7:44am UTC](https://discuss.ocaml.org/t/ann-ocamlformat-0-14-2/5754 "2020-05-12T07:44:23Z")

</div>

We are pleased to announce the release of ocamlformat 0.14.2. This minor release improves the recent 0.14.0 and 0.14.1 releases regarding the doc-comments option. How to migrate from 0.13.0 Here are the changes of the d…

---

## [Ocamlformat and infix operators](https://discuss.ocaml.org/t/ocamlformat-and-infix-operators/5647)

<div class="topic-metadata">

**Author:** [@orbitz](https://discuss.ocaml.org/u/orbitz)\
**Replies:** 7\
**Last updated:** [May 1, 2020, 4:05pm UTC](https://discuss.ocaml.org/t/ocamlformat-and-infix-operators/5647 "2020-05-01T16:05:15Z")

</div>

I’ve been looking at switching to ocamlformat and I really like it. There is one case that I so far have not been able to get how I like. I do realize that ocamlformat is not trying to be a one-size fits all but it seem…

---

## [Ocamlformat 0.14.1 match-indent broken?](https://discuss.ocaml.org/t/ocamlformat-0-14-1-match-indent-broken/5648)

<div class="topic-metadata">

**Author:** [@orbitz](https://discuss.ocaml.org/u/orbitz)\
**Replies:** 2\
**Last updated:** [April 29, 2020, 8:50am UTC](https://discuss.ocaml.org/t/ocamlformat-0-14-1-match-indent-broken/5648 "2020-04-29T08:50:01Z")

</div>

I have match-indent set to 2 in my .ocamlformat I would expect the | to be indented to the right but the results I’m getting are below. Is this a bug or am I not understanding match-indent? let f x = match x with …

---

## [Consistent indentation with ocamlformat?](https://discuss.ocaml.org/t/consistent-indentation-with-ocamlformat/5524)

<div class="topic-metadata">

**Author:** [@BrendanLong](https://discuss.ocaml.org/u/BrendanLong)\
**Replies:** 8\
**Last updated:** [April 23, 2020, 9:27pm UTC](https://discuss.ocaml.org/t/consistent-indentation-with-ocamlformat/5524 "2020-04-23T21:27:41Z")

</div>

I’m looking to switch to ocamlformat, but the one thing I can’t figure out is how to get consistent indentation levels. Example using default settings: let () = (\* 2 space indent \*) \[\] |\> ListLabels.iter ~f:(fun …

---

## [\[ANN\] OCamlformat 0.14.0](https://discuss.ocaml.org/t/ann-ocamlformat-0-14-0/5435)

<div class="topic-metadata">

**Author:** [@emillon](https://discuss.ocaml.org/u/emillon)\
**Replies:** 23\
**Last updated:** [April 16, 2020, 1:25pm UTC](https://discuss.ocaml.org/t/ann-ocamlformat-0-14-0/5435 "2020-04-16T13:25:58Z")

</div>

On behalf of the development team, I’d like to announce the release of ocamlformat version 0.14.0 :tada:. Here are the main highlights of this release: Support for OCaml 4.10 This means both that it compiles and runs u…

---

## [How to use metaocaml with ocamlformat?](https://discuss.ocaml.org/t/how-to-use-metaocaml-with-ocamlformat/5036)

<div class="topic-metadata">

**Author:** [@ale](https://discuss.ocaml.org/u/ale)\
**Replies:** 3\
**Last updated:** [January 18, 2020, 3:15am UTC](https://discuss.ocaml.org/t/how-to-use-metaocaml-with-ocamlformat/5036 "2020-01-18T03:15:37Z")

</div>

I use vim+ocamlformat to edit OCaml files. However, when I edit files with brackets from BER MetaOCaml, the bracket syntax gets expanded to attributes. e.g. let \_ = .\<1\>. expands to let \_ = (1 \[@metaocaml.bracket\]). Is …

---

## [Type indentation vs match indentation](https://discuss.ocaml.org/t/type-indentation-vs-match-indentation/4893)

<div class="topic-metadata">

**Author:** [@hongchangwu](https://discuss.ocaml.org/u/hongchangwu)\
**Replies:** 4\
**Last updated:** [December 19, 2019, 7:58pm UTC](https://discuss.ocaml.org/t/type-indentation-vs-match-indentation/4893 "2019-12-19T19:58:38Z")

</div>

When discussing ocamlformat configs with some people, one interesting point came out. The vast majority of existing OCaml code is formatted using type\_indent = 2 and match\_indent = 0 ( using ocamlformat terminology): ty…

---

## [Docked lists in ocamlformat 0.11](https://discuss.ocaml.org/t/docked-lists-in-ocamlformat-0-11/4559)

<div class="topic-metadata">

**Author:** [@Leonidas](https://discuss.ocaml.org/u/Leonidas)\
**Replies:** 5\
**Last updated:** [October 23, 2019, 2:49pm UTC](https://discuss.ocaml.org/t/docked-lists-in-ocamlformat-0-11/4559 "2019-10-23T14:49:23Z")

</div>

Hi, I have code formatted by ocamlformat like this: \[ "Something"; "else"; "entirely" \] When I upgrade to ocamlformat 0.11 it reformats it like this: \[ "Something"; "else"; "entirely"; \] Which makes my d…

[Next page](https://discuss.ocaml.org/tag/ocamlformat/105.md?match_all_tags=true&page=1&tags%5B%5D=ocamlformat)
