Skip to content
Guidehurst

Developer tools · 7 tools compared

Top 7 code formatters for polyglot repos enforced in pre-commit and CI

The Guidehurst Editorial Team
Published Last updated Facts checked 21 November 2026
Cover for “Top 7 code formatters for polyglot repos enforced in pre-commit and CI”: Developer tools shortlist with the logos of Prettier, dprint, Spotless and Black

Prettier, dprint and Spotless are the first three tools on this shortlist for keeping one consistent code style across a repository with several languages, enforced through pre-commit hooks and CI. It is written for teams maintaining polyglot and monorepo codebases. The remaining four tools (Black, clang-format, shfmt and google-java-format) each cover a specific language and fit alongside a multi-language formatter.

The shortlist

  1. Prettier logo#1PrettierTeams that want an opinionated formatter in editors and git hooks
  2. dprint monogram#2dprintMonorepos that want one formatter CLI and one config
  3. Spotless logo#3SpotlessGradle, Maven or sbt based repositories

Side-by-side comparison

7 tools, in editorial order of fit
ToolWho it is forPlatformsPricing
Prettier logoPrettierPrettierTeams that want an opinionated formatter in editors and git hooksMost editors; online try-it option availablePricing on prettier.io
dprint monogramdprintdprintMonorepos that want one formatter CLI and one configSingle static binary; install via shell script, PowerShell, npm, Homebrew or CargoPricing on dprint.dev
Spotless logoSpotlessDiffplugGradle, Maven or sbt based repositoriesGradle, Maven, sbt and other build tools; VS Code and IntelliJ integrations for Spotless for GradlePricing on github.com
Black logoBlackPython Software FoundationThe Python part of a mixed-language repositoryNot stated on official pagesPricing on black.readthedocs.io
clang-format monogramclang-formatLLVM ProjectC and C++ code in a shared repositoryStandalone tool and editor integrationsPricing on clang.llvm.org
shfmt logoshfmtmvdanShell scripts inside a polyglot repoMany operating systems and package managers; Docker imagesPricing on github.com
google-java-format logogoogle-java-formatGoogleJava modules that follow Google Java StyleJDK or GraalVM native binary; IntelliJ and Eclipse pluginsPricing on github.com

Quick verdict by need

  • Prettier if you need teams that want an opinionated formatter in editors and git hooks.
  • dprint if you need monorepos that want one formatter CLI and one config.
  • Spotless if you need gradle, Maven or sbt based repositories.
  • Black if you need the Python part of a mixed-language repository.
  • clang-format if you need c and C++ code in a shared repository.
  • shfmt if you need shell scripts inside a polyglot repo.

Tool details

Prettier logo

#1 · Prettier

Prettier

Teams that want an opinionated formatter in editors and git hooks

Go to vendor site
Homepage of Prettier
Homepage screenshot, Nov 2026

Prettier is an opinionated code formatter that integrates with most editors and acts as a fully automatic style guide. It aims to end ongoing debates over code style.

Documented strengths

  • Opinionated, fully automatic style guide
  • Runs in pre-commit scripts or githooks
  • Formats on save, with editor key bindings
  • Built-in support for Lightning Web Components (LWC)
  • Can clean up an existing inconsistent codebase

Documented limits

Its official materials are framed mainly around JavaScript developers, and the facts we verified do not list a full language set. Teams with many non-web languages should check the vendor documentation for coverage.

Who it is for
Teams that want an opinionated formatter in editors and git hooks
Platforms
Most editors; online try-it option available
Pricing
See the vendor's own pricing page for current plans and costs. prettier.io
Facts checked
21 November 2026

Why it is placed here: It opens the list because its documentation explicitly covers running as part of pre-commit scripts or githooks, and it can clean up an existing inconsistent codebase quickly.

dprint monogram

#2 · dprint

dprint

Monorepos that want one formatter CLI and one config

Go to vendor site
Homepage of dprint
Homepage screenshot, Nov 2026

dprint is a pluggable, configurable code formatting platform written in Rust. It aims to be a single formatting tool for every language in a repository.

Documented strengths

  • Official plugins for TypeScript/JavaScript, JSON, Markdown, TOML, Dockerfile, SQL and Jupyter notebooks
  • dprint check verifies code is already formatted
  • Wrapper plugins for Prettier, Biome and Oxc, plus an Exec plugin for any other CLI formatter
  • Plugins pinned and versioned in config, loaded from a URL or file path
  • Incremental caching by default

Documented limits

Official plugins cover the languages listed above. Teams that need other languages should check the vendor documentation for community plugins or use the Exec plugin to wrap an existing formatter.

Who it is for
Monorepos that want one formatter CLI and one config
Platforms
Single static binary; install via shell script, PowerShell, npm, Homebrew or Cargo
Pricing
See the vendor's own pricing page for current plans and costs. dprint.dev
Facts checked
21 November 2026

Why it is placed here: It sits second because it is designed around the polyglot case: one CLI, one dprint.json, and a dprint check command for CI.

Spotless logo

#3 · Diffplug

Spotless

Gradle, Maven or sbt based repositories

Go to vendor site
Homepage of Spotless
Homepage screenshot, Nov 2026

Spotless formats many languages using Gradle, Maven, sbt or other build systems. A formatter is conceptually a function from unformatted to formatted string.

Documented strengths

  • check and apply commands for Gradle and Maven
  • Ratcheting from origin/main or another git ref
  • Automatic idempotency and misconfigured-encoding safeguards
  • Formatter steps including google-java-format, Palantir Java format and Prettier
  • Fast incremental formatting and build-cache support on fresh checkout

Documented limits

It is documented around build-system integration, so repositories without Gradle, Maven, sbt or another supported tool should check the vendor documentation first. Support differs by formatter and build-system combination, as the project accepts partial support contributions.

Who it is for
Gradle, Maven or sbt based repositories
Platforms
Gradle, Maven, sbt and other build tools; VS Code and IntelliJ integrations for Spotless for Gradle
Pricing
See the vendor's own pricing page for current plans and costs. github.com
Facts checked
22 November 2026

Why it is placed here: It comes third because it suits repositories already organized around a JVM-style build system, with check and apply commands that fit CI.

Black logo

#4 · Python Software Foundation

Black

The Python part of a mixed-language repository

Go to vendor site
Homepage of Black
Homepage screenshot, Nov 2026

Black is an uncompromising Python code formatter. Using it means ceding control over hand-formatting in exchange for speed and determinism.

Documented strengths

  • Produces the smallest diffs possible
  • Checks that reformatted code still produces an equivalent AST
  • GitHub Actions and version control integration
  • Works with Jupyter Notebooks
  • Can run as a server via blackd

Documented limits

Documented for Python only; teams with other languages need additional formatters. The --fast option skips the equivalent-AST safety check.

Who it is for
The Python part of a mixed-language repository
Platforms
Not stated on official pages
Pricing
See the vendor's own pricing page for current plans and costs. black.readthedocs.io
Facts checked
21 November 2026

Why it is placed here: It is first among the single-language tools because it handles the Python portion of a mixed repository with documented version control and GitHub Actions integration.

clang-format monogram

#5 · LLVM Project

clang-format

C and C++ code in a shared repository

Go to vendor site
Homepage of clang-format
Homepage screenshot, Nov 2026

ClangFormat is a set of tools built on LibFormat that formats C, C++, Java, JavaScript, JSON, Objective-C, Protobuf and C# code.

Documented strengths

  • .clang-format found in parent directories, with a fallback style
  • Dry-run mode shows changes without applying them
  • -i edits files in place
  • Skips files listed in .clang-format-ignore
  • Preset styles and line-range formatting

Documented limits

Documented for the languages listed above. Teams using other languages should pair it with another formatter and check the vendor documentation for pre-commit setup.

Who it is for
C and C++ code in a shared repository
Platforms
Standalone tool and editor integrations
Pricing
See the vendor's own pricing page for current plans and costs. clang.llvm.org
Facts checked
21 November 2026

Why it is placed here: It follows because it covers C-family and several other languages through a .clang-format file that is discovered from parent directories, which suits a shared repository layout.

shfmt logo

#6 · mvdan

shfmt

Shell scripts inside a polyglot repo

Go to vendor site
Homepage of shfmt
Homepage screenshot, Nov 2026

shfmt is a shell script formatter, part of the mvdan/sh project, which also provides a parser and interpreter for POSIX Shell, Bash, Zsh and mksh.

Documented strengths

  • Documented default style
  • Deliberately limited formatting options
  • Supports POSIX Shell, Bash, Zsh and mksh syntax
  • sh-checker GitHub Action uses shfmt
  • Release tags published as Docker images

Documented limits

Formatting cannot be disabled for ranges of lines, so teams that need partial opt-outs should check the vendor documentation. It formats shell only.

Who it is for
Shell scripts inside a polyglot repo
Platforms
Many operating systems and package managers; Docker images
Pricing
See the vendor's own pricing page for current plans and costs. github.com
Facts checked
21 November 2026

Why it is placed here: It earns a place for repositories with shell scripts, with a deliberately small set of options that supports team-wide consistency, and it has a CI action in sh-checker.

google-java-format logo

#7 · Google

google-java-format

Java modules that follow Google Java Style

Go to vendor site
Homepage of google-java-format
Homepage screenshot, Nov 2026

google-java-format is a program from Google that reformats Java source code to comply with Google Java Style.

Documented strengths

  • Maven plugin can deploy it as a pre-commit git hook
  • GitHub Action formats Java files on push
  • Script to reformat only the changed lines of a patch
  • --style flag selects Google or AOSP style
  • Column limit configurable, default 100

Documented limits

It deliberately offers almost no configurability, and it must run on a JDK at least as new as the Java language version being formatted. GraalVM-based native binaries are available as an alternative.

Who it is for
Java modules that follow Google Java Style
Platforms
JDK or GraalVM native binary; IntelliJ and Eclipse plugins
Pricing
See the vendor's own pricing page for current plans and costs. github.com
Facts checked
21 November 2026

Why it is placed here: It sits last because it covers one language, but it has a documented Maven plugin that deploys it as a pre-commit git hook and a GitHub Action for formatting on push.

Sources

Related guides

How we compiled this

We looked at three things: fit with the use case of enforcing one style across many languages in a shared repository, the capabilities each vendor documents (check modes, configuration files, ignore mechanisms, hook and CI integrations), and the deployment and platform information on the official pages. Every statement in this list comes from official vendor pages, each carrying a check date. Anything a vendor does not document is left out or flagged as not stated.

The order reflects editorial fit for this use case, explained in words in each entry: multi-language tools and tools that wire easily into a shared repo workflow come first, and single-language formatters follow. It does not say one tool is better overall, since a Python-only formatter and a multi-language platform solve different parts of the problem. The list is built from documentation rather than product trials, so check each vendor's documentation against your own language mix before adopting a tool.

Order used: Ordered by number of languages covered and ease of wiring into a shared repo workflow, broadest first.

Our full method · Disclosure

Common questions

How do I run a code formatter in pre-commit hooks?

Prettier documents running as part of pre-commit scripts or githooks, and google-java-format has a Maven plugin that deploys it as a pre-commit git hook. For other tools, check the vendor documentation for hook setup.

Is there one formatter for every language in a repository?

dprint aims to be a single formatting tool for every language in a repository. Its official plugins cover TypeScript/JavaScript, JSON, Markdown, TOML, Dockerfile, SQL and Jupyter notebooks, and an Exec plugin can wrap other CLI formatters.

How can CI check formatting without changing files?

dprint check verifies that code is already formatted, Spotless provides check and apply commands for Gradle and Maven, and clang-format has a dry-run mode that shows what would change without applying it.

Can I format only changed code when adopting a formatter in an existing repo?

Spotless supports ratcheting from origin/main or another git ref, and google-java-format provides a script to reformat only the changed lines of a patch.

Which formatters work with build systems like Gradle or Maven?

Spotless works with Gradle, Maven, sbt and other build tools. google-java-format also has a Maven plugin for pre-commit use.

The editorial order is unpaid. A vendor can buy one labelled featured slot per guide, but it gets the same fact check as everyone else and cannot alter or remove a competitor's entry. Guidehurst is independent. Product names and logos belong to their respective owners.