Prettier: one style for all your code, without the arguments
Prettier is a tool that reads your source files and rewrites them into a single, fixed format — it decides where the spaces go, where the commas sit, where the brackets open and how deep the indentation is — so your team stops spending time arguing about style and stops producing changes that are only about how the code looks.

What it does
Picture two developers looking at the same change. One puts the brace on the same line as the function, the other drops it to the next line. They do not disagree about what the code does — they disagree about how it looks. Multiply that conversation by a hundred changes a month and you have spent real time on nothing. Prettier exists to end that conversation once and for all.
It is a formatter: it reads your source files and rewrites them under one uniform set of rules. Where a space goes after a comma, where a bracket opens and closes, how deep an indent is, how long a line may get before it breaks — the tool decides all of it, the same way, every time, in every file. You do not decide it, and neither does each person on your team separately.
The point hides in a word the maintainers use themselves: Prettier is opinionated. It has a view. You do not configure it down to every detail — you give it a few choices by hand (how wide a line should be, whether quotes are single or double, whether it adds a trailing comma) and otherwise it decides for you. That is not a flaw, it is the reason it exists: one decision for everyone, made once, and the arguments end.
In practice you run it two ways. The first is the check: you tell it “look at these files and tell me if any of them is not in the right shape” — and it answers without touching anything. The second is the fix: you tell it “rewrite them”, and it does. Those two modes are also how you fit it into your workflow: it can run every time you save a file in your editor, it can run before a change is recorded (the so-called “pre-commit hook”), and it can run automatically on the server that receives your team’s changes (that is “CI”).
And it is not only about JavaScript. Prettier formats TypeScript, JSON, CSS, HTML, Markdown, YAML and other languages — so one tool covers almost everything you meet in a modern project.
The numbers speak for themselves. Today, as I read them from the repository and the package registry: 52,408 stars on GitHub, 5,029 forks, 182,688,964 downloads a week — more than one hundred and eighty million times a week somebody downloads this package. The repository has existed since November 2016, and the last change to its code was today. This is not a tool someone left in a corner.
What it does not do
The most important thing to know: Prettier is not a linter. A “linter” is the tool that hunts for logic mistakes and bad practice — it tells you “this variable is never used”, “this function is too long”, “this call is old and should not be used”. Prettier does none of that. It finds no bugs, suggests no better way, warns you about nothing. It changes only the look. It does not touch the behaviour of your code — and that is not a promise, it is measured: I ran a program before and after formatting, and the output was identical, word for word.
Second: it does not fix broken code. If a file has a syntax error, Prettier does not try to guess what you meant — it refuses to touch it and shows you the error. That is the right behaviour: a tool that fixes things by guessing is more dangerous than one that stops.
Third: it is not a server or a service. It loads no “schema” into a model, it sends your code nowhere, it has no account and no key. It is a command that runs on your own machine, in a terminal, and ends there.
And fourth: it does not replace a human code review. It makes one class of comments unnecessary — all the “add one more indent here” — but it does not judge whether the code is correct or whether it solves the right problem. That stays your job, or someone else’s.
Two words first
Formatter: a program that rewrites the text of your code into a fixed shape without changing what it does. What a spell-checker does for paragraphs, this does for lines of code.
Opinionated: having a view of its own that is not renegotiated on every detail. In tools this is a good thing: it means there is one answer to “how should this look”, so nobody has to argue about it.
Linter: a tool that hunts for mistakes and suspicious practice in code — unused lines, wrong calls, traps. It is a different job from formatting, and usually the two work together.
Pre-commit hook: a small script that runs before a change is recorded in your local history. Put Prettier there and no unformatted change ever gets past it.
CI (continuous integration): the automated server that runs checks every time someone sends changes to a repository. Put the Prettier check there (not the fix) and a change with inconsistent style is rejected before a human sees it.
Who it is for
For teams. The more hands touch the same code, the more arguments there are about style — and Prettier makes them unnecessary, because there is no longer “each person’s style”, there is one.
For anyone maintaining old code. Once you “straighten” all your files with Prettier, every later change shows only what changed in substance, not where a space moved. Diffs get smaller and easier to read.
And for anyone working alone but with many languages in one project: one tool, one config file, everything in line.
It is not for someone who wants to decide every comma individually. If the style of your code is something you build by hand and never hand to a tool, Prettier will annoy you — because you are handing it exactly that decision.
Installation
The commands are for a Node environment, from the terminal. One per block, one under the other:
mkdir ptest && cd ptestnpm init -ynpm install --save-dev prettier@3.9.10Check that it landed:
npx prettier --versionPrettier works with no configuration at all — that is the whole point. If you want to change a few things, you add a .prettierrc file:
{
"printWidth": 80,
"singleQuote": true
}And two ready commands in package.json, so you do not have to remember the full name each time:
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check ."
}To run it before every recorded change, the simplest is a .git/hooks/pre-commit file:
#!/bin/sh
npm run format:check || exit 1Use with any LLM
Prettier is not a server. It has no tool list, no schema, and it connects to no model. It is a command with subcommands (--check, --write), and whatever assistant you hand it to, the usage is the same shell line.
Claude Code
Ask it in plain words (“format this file with Prettier”) or give it the command directly:
npx prettier --write path/to/file.jsCodex CLI
Ask it in words (“run the formatting check on src”) and it translates into a shell command:
npx prettier --check src/**/*.jsnpx prettier --write src/**/*.jsCursor
Same shape — from the built-in terminal, or by asking in the chat:
npx prettier --write path/to/file.jsThe one thing worth keeping: a command-line tool does not need to be “declared” anywhere for an assistant to use it — it only needs to know the command.
Where it wins, where it loses
It wins on the time that is not spent: when format is not up for debate, code review deals only with substance. It wins on consistency: the same rule in every file means nobody brings their own style into someone else’s project, and a new teammate does not have to learn internal conventions. And it wins on reading diffs: when every change passes through the tool, the comparisons show what changed in logic, not where a space moved.
It loses on control: if you have a very particular style that is not covered, you will need customisation or another tool on top. It also loses for anyone expecting something it does not do: it finds no bugs (you need a linter), it does not fix broken syntax (it stops and shows you where). And it asks for a small shift in mindset: you hand the style decision to a tool, and the tool does not negotiate.
One practical thing you will meet on day one: the first time you run Prettier on a project that has existed for a while, it will rewrite many files at once — and that first change looks enormous, even though nothing about the logic changed. That frightens whoever reads the diff. The fix is well known: make the first formatting its own, separate pass, tell your team “this change is format only”, and from the next day on every diff shows only the real work.
Test
I set up a clean folder and ran the steps exactly as written above. The measurements:
mkdir ptest && cd ptest
npm init -y
npm install --save-dev prettier@3.9.10I made a test.js file with deliberately messy code — double spaces, brackets glued to the same line, inconsistent indentation — and inside it I put a trap word, TRAP-OK-36, so I would know the tool really rewrote this file and did not output something unrelated. Then:
npx prettier --check test.js
npx prettier --write test.jsResults, measured:
- Installation took 3 seconds and left 9.7 MB on disk — in one package, with no transitive dependency. The version that landed was 3.9.10.
--checkon the messy file returned exit code 1 and printed “Code style issues found”. So it tells you if a file needs formatting without touching it.--writereturned exit code 0 and rewrote the file: it added a space after commas, opened brackets onto their own lines, tidied the indentation, aligned the arrow functions. And the trap wordTRAP-OK-36stayed inside the file — not a letter lost.- And the proof it does not change behaviour: I ran the program before and after formatting — identical output, word for word.
And the failure, because this is the most useful part: I deliberately handed it a file with broken syntax — a missing parenthesis. Prettier refused to touch it, returned exit code 2, and said exactly where: SyntaxError: Unexpected token, expected "," (1:17) — with the line and column, and a caret under the spot that does not fit. So it does not guess in front of broken code: it fails, shows you where, and leaves no tidy-looking result behind.
What it costs
It is not an MCP server, so it loads no schema into the model: zero tokens on either side. The cost here is disk, time, and one version requirement.
And it is the lightest tool in its class: the package pulls in no other dependency — it is one package, not a tree. Measured in a clean folder: installation took 3 seconds and left 9.7 MB on disk. The package file itself is 9.96 MB unpacked, from the registry’s unpackedSize field.
The requirement: Node 14 or newer — from the package’s engines field, not from the README. It needs no graphics card, no account, no key.
In money: zero. It is free software under the MIT licence. The expense is the seconds you save and the arguments that never happen — and you can only measure those on your own team.
Verdict
This is one of those tools that do not impress and will never go on a demo, but you use them every day: 52,408 stars, 182.7 million downloads a week, maintained, MIT licensed, with zero dependencies and just 9.7 MB. Its strongest point is not technical — it is social: it removes an entire category of argument from the room. And the most important thing to keep: it formats, it does not fix. What your code does stays yours; what it looks like is decided for you.
Sources: