Contents
Every team eventually argues about tabs, quotes, and trailing commas. The argument is boring, so we automate it: a formatter owns the canonical shape of the code, and CI rejects anything that drifts. But when you are looking at a file — or a legacy module nobody has touched in two years — the useful question is not “is it formatted?” It is “how far from canonical is it, and against whose rules?”
The Code Formatter Comparator is the newest interactive tool on CodeIntel. Paste a source file, choose a target formatter, and it reports, rule by rule, where your code diverges from that formatter’s conventions — with line numbers, a consistency score, and a comparison table of how the four mainstream formatters disagree.
Try the Code Formatter Comparator →
What it does
Pick a target — Prettier, Black, gofmt, or rustfmt — and paste code. The tool runs twelve deterministic text rules and returns:
- A findings list, each with a severity (error, warning, info), the rule name, the line number, what was expected, and what it found.
- A 0–100 consistency score with a grade (canonical, close, drifting, off-style), weighted by severity and normalized by file size.
- A comparison table showing, for every rule, what each of the four formatters expects — so you can see the disagreement directly instead of reading four docs.
How the heuristic works
The tool is a static text analyzer, not a formatter. It never rewrites your code and it never calls a network service. It reads the file character by character and applies fixed rules:
- Whitespace correctness — trailing whitespace, a missing final newline, and runs of more than two blank lines.
- Indentation — whether the file uses tabs or spaces, whether it mixes both (a hard error), and whether the dominant indent width matches the target (2 spaces for Prettier, 4 for Black and rustfmt, tabs for gofmt).
- Quotes — it counts single- versus double-quoted strings and flags the file when the wrong style dominates. All four formatters prefer double quotes, per Prettier’s options reference and Black’s code style.
- Semicolons — for JavaScript and TypeScript, it finds statement lines that look complete but omit the terminator Prettier would add.
- Trailing commas — for multi-line array literals it flags a missing final comma, the style Prettier’s
trailingComma: "all"and Black’s magic trailing comma both expect. - Line length — against the target’s print width: 80 for Prettier, 88 for Black, 100 for rustfmt; gofmt imposes no hard limit.
- Bracket spacing and blank-line hygiene round out the set.
Each rule is a small, readable function over the diff-free text. Run the same input twice and you get byte-identical output — the score is a deterministic function of the code, not a model’s guess.
What it does not do
Honesty matters more than a demo here. The comparator:
- Does not reformat. It tells you what is off, not how to fix it. Run the real formatter for that.
- Has no parser and no AST. It counts characters and matches patterns, so indentation inference can misread line continuations, wrapped expressions, and multi-line strings. Quote counts do not distinguish a string from a comment containing a quote.
- Checks arrays, not braces, for trailing commas. A brace could open an object literal or a function body, and the two want different things; the rule deliberately skips that ambiguity rather than guess and produce false positives.
- Is a convention checker, not a linter. It will not find bugs, unused variables, or type errors.
Use it to answer “which of these two files is closer to our standard?” and “what will break when we turn on the formatter?” — then let the formatter itself settle the details.
How to use it
- Open the tool.
- Pick your target formatter from the four chips.
- Paste a file, or hit Load sample to see a canonical file and a messy one side by side.
- Read the findings, then Copy report to paste a Markdown summary into a ticket or a migration checklist.
Everything runs in your browser. Nothing is uploaded, stored, or sent anywhere — the page is a single static file with no backend and no dependencies.
Where it fits
The comparator is the fourth tool shipped in the Code Transformation track of the tools roadmap, alongside the Language Transpiler, Refactoring Assistant, and Commit Message Generator. The roadmap tracks eighteen planned tools across four categories; this one is done and live, and two more in the transformation track are still queued.
The point of the series is narrow and consistent: take a code-quality question teams argue about by vibes, encode it as a deterministic heuristic you can run in the browser, and be explicit about what the heuristic cannot see.




