What is the JSON Formatter?
The JSON Formatter takes minified or messy JSON and transforms it into a readable, consistently indented structure — or compresses pretty-printed JSON into a single line for production payloads. It validates input against the strict JSON specification (RFC 8259), reports the location of syntax errors, and can automatically repair common mistakes with the Fix JSON mode.
The most common JSON syntax errors
| Error | Example | Fix |
|---|---|---|
| Trailing comma | {"a": 1,} | Remove the comma before } or ] |
| Single quotes | {'a': 1} | JSON requires double quotes |
| Unquoted keys | {a: 1} | Wrap keys in double quotes |
NaN / Infinity | {"x": NaN} | Use null or a string instead |
| Comments | // note | Strip comments — strict JSON has none |
The Fix JSON button repairs most of these automatically, which is handy when pasting JavaScript object literals or JSON5-style config snippets.
Why sort keys?
Enabling Sort Keys orders all object properties alphabetically at every nesting level. Sorted output makes two JSON documents directly comparable in a diff tool, stabilizes version-control diffs for committed fixtures, and makes large payloads easier to scan. Note that the JSON spec treats key order as insignificant, so sorting never changes the data’s meaning — but if a downstream consumer incorrectly depends on key order, keep sorting off.
Reading the structure statistics
After formatting, the stats bar reports total keys, maximum nesting depth, and object/array counts. These are practical signals: payloads deeper than 5–6 levels are hard to consume and often indicate over-nesting; thousands of keys in one object suggest data that belongs in an array of records. The output size readout helps you estimate transfer cost before and after minification.