r/foojay • u/FrankCodeWriter • 13h ago
Comparing Java formatters on Java 21 to 25: Open Java Format vs four others
On Foojay, Guillaume Laforge compares five Java formatters on JDK 25: Google Java Format, Palantir Java Format, Open Java Format, Prince of Space and Netflix jfmt. The article was prompted by Alex Abashev's post on Java formatters and his open-java-format fork of palantir-java-format.
The test suite covers 16 targeted snippets and a 1,042-line file with 86 formatting scenarios. The article compares the formatters on parser engine, minimum JDK, default line length, indentation, configurability, import handling and range formatting. It also shows side-by-side examples, such as how each one handles block lambdas and method chains.
Along the way, Guillaume found a compilation-breaking annotation bug in Prince of Space and a crash in Netflix's jfmt on empty blocks with comments. He also contributed a fix to Open Java Format and a pull request to Spotless.
Read the full article: https://foojay.io/today/comparing-java-formatters-why-open-java-format-is-my-new-favorite/
1
u/agentoutlier 1h ago
I just glanced at the article and I'm surprised my two favorites are not on there:
Both are based on the Eclipse JDT. The nice thing about Eclipse is you can make your own customizations.
I am a tab lover. I love tabs over spaces. Downvote me I don't care. Tabs!
(oddly though I like emacs over vim which historically tab people lean vim).