# \[ANN\] Experiment: format-line

**URL:** <https://discuss.ocaml.org/t/ann-experiment-format-line/17854>\
**Category:** Ecosystem\
**Created:** [February 27, 2026, 10:37am UTC](https://discuss.ocaml.org/t/ann-experiment-format-line/17854 "2026-02-27T10:37:31Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![EmileTrotignon](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/emiletrotignon/32/5913_2.png) [@EmileTrotignon](https://discuss.ocaml.org/u/EmileTrotignon)\
**Post date:** [February 27, 2026, 10:37am UTC](https://discuss.ocaml.org/t/ann-experiment-format-line/17854/1 "2026-02-27T10:37:31Z")

</div>

I made this little experiment a while back: [GitHub - ahrefs/format-line](https://github.com/ahrefs/format-line)

The idea is to provide a complement to ocp-indent to decide which token should be separated by whitespace and which should not. For now it is based only on lexing information, which make the code simple but also does not always provide enough information to have a nice formatting.

An idea of the output can be read here: [format-line/test/run.t at master · ahrefs/format-line · GitHub](https://github.com/ahrefs/format-line/blob/master/test/run.t)

The project itself is formatted with ocamlformat, and in the there is a diff of what this changes compared to ocamlformat, on the main source file.

I think this approach could be improved by having a hybrid ast-token stream datastructure. Something where you work on a stream of token but you can query the AST context of a given token.

What do you think ?

---

_[View the full topic](https://discuss.ocaml.org/t/ann-experiment-format-line/17854)._
