How to Format and Validate JSON Data Online
JSON (JavaScript Object Notation) looks like a JavaScript object, but it's stricter — and that difference is exactly why "minified" or hand-edited JSON so often breaks.
How JSON differs from a JS object literal
- Keys must be wrapped in double quotes —
{name: "x"}is invalid JSON; it must be{"name": "x"}. - No trailing commas are allowed after the last item in an array or object.
- No comments are allowed anywhere in JSON.
- Strings must use double quotes, not single quotes.
- Functions,
undefined, andNaNcannot appear in JSON at all.
Because these rules are strict, a single misplaced comma or unquoted key is enough to make an entire JSON payload fail to parse — with an error message that doesn't always point clearly at the problem.
Formatting JSON for readability
API responses and config files are frequently returned or stored minified — all on one line, no spacing — to save bytes. That's efficient for machines and unreadable for humans. Formatting adds indentation and line breaks back in without changing a single value, so you can actually see the structure: which keys are nested inside which objects, and how deep an array goes.
Validating JSON at the same time
A useful side effect of running JSON through a formatter is that it validates the structure as part of formatting. If the JSON is malformed, the formatter can't produce output and will tell you it failed to parse — which is often the fastest way to discover a stray comma or unclosed bracket.
How to do it here
Set the language selector on the JS formatter to JSON (or leave it on Auto-detect — it recognizes JSON automatically), paste your data, and click Format. If it's valid, you'll get a cleanly indented result instantly, entirely in your browser. If it's not, you'll see an error instead of silently broken output.
Once your JSON is readable, you may want to compress it back down before sending it over the network — see minify vs beautify for when that trade-off makes sense.