How to use the code beautifier
- Choose Beautify or Minify, then the language: JavaScript, CSS, HTML or JSON.
- Paste your code or drop files (several at once for a batch).
- Pick the indentation: 2 spaces, 4 spaces or a tab. For JSON, optionally sort keys.
- Press Beautify and copy or download the result.
- Open the diff view to see exactly what changed.
How it works
| Language | Engine | What it does |
|---|---|---|
| JavaScript | js-beautify | Re-indents blocks, puts statements on their own lines, keeps up to two blank lines |
| CSS | js-beautify | One declaration per line, indented rules and at-rules |
| HTML | js-beautify | Indents nested elements, keeps inline elements on one line |
| JSON | Built-in parser | Parses strictly, then prints with your indentation; can sort keys |
Switch to Minify to compress code again with the same engines as the dedicated minifiers.
Worked examples
function a(){return 1}becomes a three-line function with the body indented..a{color:red}becomes a rule block withcolor: redon its own indented line.{"b":1,"a":2}with Sort JSON keys becomes{ "a": 2, "b": 1 }on separate lines.
Tips and common mistakes
- Pick the right language: formatting HTML as JavaScript gives odd results.
- Fix JSON errors first: the beautifier won’t guess what invalid JSON meant.
- Don’t expect comments back: minifiers remove them, and a beautifier can’t restore them.
- Match your project’s style: use the same indentation as your editor or formatter config to avoid noisy diffs.
Why use this beautifier
It covers four languages in one place, runs privately in your browser, shows a diff, handles batches with a ZIP download and works fully with a keyboard and screen reader.
When beautifying helps most
Beautified code is much easier to review and debug. Use it to read a minified library before deciding whether to depend on it, to inspect what a build tool or CMS outputs, to compare two versions of a config file in a diff, or to tidy a snippet copied from a chat or an email before committing it. For JSON in particular, consistent indentation and sorted keys make version-control diffs show only the real changes, which speeds up code review.