How to Format, Validate, and Beautify JSON
2026-06-12
Short answer: Paste your JSON into the in-browser JSON formatter, hit format, and you get clean, indented output instantly — or a clear error with the line number if it's invalid. It runs locally, so the API response you're debugging (and any tokens or PII inside it) never leaves your machine.
Minified vs pretty JSON
Same data, two shapes. Minified JSON strips every space and newline so it's as small as possible — great for shipping over the wire:
{"id":1,"name":"Milo","roles":["dev"]}
Pretty (beautified) JSON adds indentation and line breaks so a human can actually read it:
{
"id": 1,
"name": "Milo",
"roles": ["dev"]
}
You format for reading and debugging; you minify for production. The formatter does both directions.
Format and validate in the browser
- Copy your JSON — an API response, a config file, a log line, whatever.
- Paste it into the JSON formatter.
- Click format. Valid JSON comes back indented; invalid JSON shows the error and the line/column where the parser choked.
- Fix the flagged spot (usually a trailing comma, a missing quote, or a stray
'instead of") and re-run. - Need it small again? Minify before you paste it into production config.
The validation is the underrated part. "Unexpected token at line 14" beats squinting at one wall of text trying to find the bracket that doesn't close.
The privacy angle
JSON you're debugging is rarely innocent. API responses routinely carry access tokens, session IDs, email addresses, and other PII. A lot of popular online JSON tools send your paste to their server to format it — which means that payload can end up in their logs. For a token, that's a live credential sitting in someone else's database.
An in-browser formatter parses everything locally. Want proof? Open DevTools → Network, paste a payload, and watch — nothing fires. Same trick I push for the JWT decoder: if it doesn't transmit, it can't leak.
Honest alternatives
You don't always need a website:
jq—cat data.json | jq .pretty-prints and validates, andjq -c .minifies. It's free, fast, and the right tool once you're comfortable in a terminal. Best CLI option, full stop.- Python —
python -m json.tool data.jsonformats with zero install on most machines. - Editor extensions — VS Code's Format Document (Shift+Alt+F) handles JSON natively.
- jsonlint.com and similar — they work, but they upload your JSON to validate it. Fine for dummy data, not for anything with a real token in it.
The browser tool's niche is the in-between: more convenient than memorizing jq filters, more private than a site that uploads.
FAQ
How do I find the error in invalid JSON? Paste it into a validator that reports line and column. The most common culprits are trailing commas, single quotes instead of double, and unquoted keys — JSON forbids all three.
What's the difference between JSON and a JavaScript object? JSON is stricter: keys must be double-quoted strings, no trailing commas, no comments, no functions. Valid JSON is valid JS, but not the reverse.
Should I commit minified or pretty JSON to my repo? Pretty, almost always — readable diffs matter more than a few saved bytes in source control. Minify at build/deploy time instead.
Can I convert JSON to other formats? Yes — try CSV to JSON for spreadsheet data and YAML/JSON to move between config formats, both in-browser.
— Milo 🐨