How to beautify JSON
- Paste your minified or compressed JSON into the box above.
- Choose the indentation width, four spaces suits deeply nested documents.
- Tick key sorting if you are about to compare this document against another.
- Check the message, which reports how much the document expanded.
- Copy or download the readable version.
What beautifying gives you
- Consistent indentation at 2 spaces, 4 spaces or tabs.
- Optional recursive key sorting, applied at every level of nesting.
- A report of how many characters and lines the expansion produced.
- Validation as a side effect, invalid JSON is reported rather than mangled.
- Arrays left in their original order, since array order is meaningful.
- No upload, so configuration files and API payloads stay private.
Beautifying and formatting are the same idea
The two words get used interchangeably, and for good reason: both mean taking JSON that is technically valid but unreadable and laying it out with indentation and line breaks. What this page adds is key sorting, which is a genuinely different capability and the reason to come here rather than to the plain formatter.
Everything else is the same. The data is unchanged, whitespace in JSON is insignificant, and the beautified document parses to exactly the same value as the compressed one.
Why sorting keys matters
Compare two JSON documents that describe the same thing but were produced by different systems, and the diff is usually useless. One writes id first, the other writes it last, and every line shows as changed even though the data is identical.
Sorting both documents alphabetically before comparing fixes this completely. Keys line up, and the diff shows only the values that genuinely differ. This is the standard trick for comparing configuration files across environments, API responses before and after a change, or an expected fixture against actual output.
When not to sort
- Configuration files where a human-friendly order, name, then description, then settings, aids reading.
- Documents you are handing back to a system that, incorrectly but really, depends on key order.
- Anything where the original order encodes meaning, such as an ordered set of steps stored as object keys.
Arrays are never reordered, whatever the sorting setting. Array order is meaningful in JSON and reordering it would change the data rather than its presentation.
Choosing an indentation width
Two spaces is the web default and keeps deeply nested documents from marching off the right-hand side. Four spaces is easier to scan at a glance and suits documents that are wide rather than deep. Tabs let each reader choose their own width in an editor, which is the argument for them, and they render inconsistently when pasted into other tools, which is the argument against.
Whichever you pick, be consistent within a project. Mixed indentation in a repository produces diffs full of whitespace changes that hide the real ones.
Working with large documents
Beautifying multiplies the size of a document. A compressed 200 KB payload can easily become 600 KB once indented. That is fine for reading and awkward for storing. Keep the minified version as the source of truth and beautify a copy when you need to look at it.
The JSON minifier compresses it back down, and the JSON validator gives a fuller diagnostic when a document will not parse at all. Nothing is uploaded at any point.
Comparing two documents in practice
The workflow that makes sorting worthwhile is short. Beautify both documents with the same indentation and sorting turned on, save each to a file, and run them through any diff tool, your editor's built-in comparison is fine. What remains highlighted is the genuine difference.
Without that preparation a diff is dominated by noise: one document uses two-space indentation and the other four, one lists keys in insertion order and the other alphabetically, one wraps arrays and the other does not. Every line shows as changed and the real difference hides among them. Ten seconds of normalisation turns an unreadable diff into a useful one, which is why the sorting option exists at all.