You may be asking what is a code formatter and whether your team needs one. It is a tool that rewrites source code into one consistent style automatically, so nobody argues about spacing or quotes again.
This guide is part of a wider look at the best developer tools, and it keeps the explanation in plain terms.
| Item | Value |
|---|---|
| Prettier’s first requirement | Output valid code with the exact same behavior as before formatting |
| Prettier quote style on a tie | Double quotes |
| Prettier and repeated blank lines | Collapsed into a single blank line |
| Prettier and file endings | Files always end with a single newline |
| Thoughtworks Technology Radar rating, Nov 2018 | Trial |
These figures come from the Prettier rationale page and the Thoughtworks Technology Radar entry. Tools and ratings change, so check the sources before you rely on them.
What a code formatter does to your files
A code formatter reads your source code and prints it back out in a fixed style. The Qlty documentation describes auto-formatting as using automated tools to rewrite source code files into a consistent format, as you can read in its auto-formatting guide.
The goal is readability. A University of Washington programming-languages group post from March 2024 calls code formatters tools that make source code easy to read, and notes that many modern languages ship one with their main implementation (UW PLSE).
The Qlty guide says the rules cover indentation, spacing, line breaks and more. Prettier’s rationale page adds some specific examples of what a formatter decides for you:
- Which quote style to use, choosing the one that needs the fewest escapes.
- How many blank lines to keep, collapsing several into a single blank line.
- Whether a long expression stays on one line or wraps.

Formatting is not the same as linting
A formatter changes layout, not behavior. Prettier’s rationale says its first requirement is valid output with the exact same behavior as before formatting, and that it only reformats code rather than changing what it does (Prettier rationale).
A linter works differently: it checks code and reports problems. The Thoughtworks Radar entry from Nov 2018 says Prettier flips the linter-based approach, so that instead of validating your code, it ensures your code will always be valid (Thoughtworks).
In practice teams often use both. For Python linting choices, see the breakdown of flake8 vs pylint on this site.
Why teams adopt a formatter
The Qlty documentation lists three benefits of auto-formatting (Qlty):
- Consistency: one style across the whole codebase, which is easier to read.
- Productivity: developers write code instead of adjusting whitespace by hand.
- Faster code review: clean diffs and fewer stylistic comments, so reviewers can focus on logic.
The UW PLSE post makes the review point concrete. Pull requests with inconsistent formatting are likely to bring change requests that block the merge, wasting the time of both submitter and reviewer, whereas a formatter lets the author fix those issues before review starts (UW PLSE).
The Thoughtworks entry adds a social benefit: less effort on formatting and fewer wasteful team debates about code style. It also admits you may disagree with some choices, yet concludes the benefits generally outweigh small style issues (Thoughtworks Radar).
Opinionated or line-preserving: two kinds of formatter
Not every formatter works the same way. The UW PLSE post splits them by whether they honor the page width limit: a line-preserving formatter does not, and mostly formats whitespace within each line while keeping the original line breaks (UW PLSE).
The post names gofmt as mostly line-preserving, and says such formatters are also known as unopinionated because they make few formatting decisions of their own. Line-breaking formatters instead make their own decisions from scratch.
Even opinionated tools keep a little of your input. Prettier keeps an object multi-line if there is a newline between the opening brace and the first key, though its own documentation calls that behavior a workaround, not a feature (Prettier rationale).
Common formatters by language
Most languages have a go-to tool. The Qlty docs recommend these auto-formatters in its language table (Qlty):
- Go: go fmt
- JavaScript and TypeScript: Prettier
- Python: Black
- Rust: rustfmt
That table is one vendor’s recommendation, not a ranking, and other tools exist for each language. Prettier itself started with JavaScript; the Nov 2018 Radar entry described it as having growing support for other languages (Thoughtworks).
Adding a formatter to your workflow
A formatter only helps if it runs without anyone remembering to run it. The Qlty guide describes three integration points (Qlty):
- Run it on demand, so you can reformat whenever you like.
- Add it as a Git pre-commit hook so every commit is formatted.
- Run an automated CI job on a schedule, such as nightly, and commit the results.
Thoughtworks likewise says Prettier can be used with a precommit hook or an IDE plugin. A walkthrough of how to set up pre-commit hooks covers the mechanics.
Expect one cost. The Radar entry warns that a one-time reformatting of your codebase can confuse your version control history, though it calls that a minor drawback. Also note that the page is marked as not on the current edition of the Radar, so treat its Nov 2018 Trial rating as dated (Thoughtworks).
Frequently asked questions
Does a code formatter change what my code does?
Show answer
It should not. Prettier’s rationale page says a formatter only reformats code and does not change its behavior, and treats any failure of that rule as a bug (Prettier rationale).
Is a formatter the same as a linter?
Show answer
No. A formatter rewrites layout, while a linter validates code and reports problems. The Thoughtworks Radar entry from Nov 2018 contrasts the two approaches (Thoughtworks).
Can I customize the style a formatter uses?
Show answer
Often, to a degree. The Qlty docs say these tools can typically be configured to match your team’s style guide, and Prettier offers options such as singleQuote (Qlty). Keeping overrides few preserves the benefit of having fewer style debates.
Will a formatter make my Git history messy?
Show answer
Only once, when you first reformat an existing codebase. Thoughtworks says that one-time reformatting can confuse version control history but judges it a minor drawback (Thoughtworks).



