JSON formatter: validate, format and fix common errors
Reviewed 17 November 2026 · 6 min read · Written and maintained by Toolnexo
JSON looks friendly and is unforgiving. The grammar is strict, the error messages are terse, and a trailing comma can ruin your afternoon. I've debugged enough payloads to know the failures repeat — so here they are, along with how I work through them.
Formatting is not validation
Pretty-printing adds indentation and line breaks. Validation checks the grammar. A tool that only reshuffles whitespace can hand you a beautifully formatted, completely invalid document — and you'd only find out when the API rejects it.
Our formatter parses the input with JSON.parse before it touches anything. Invalid input gets a real error with its position, not a misleadingly pretty result. That distinction is the whole point of the tool.
The errors that cause most failures
- A trailing comma after the last property or array item. JavaScript tolerates it; JSON does not.
- Single quotes or unquoted keys — fine in JS objects, invalid in JSON.
- Comments. JSON has none, no matter how much you wish it did.
- NaN, Infinity and undefined. Not JSON values, however natural they feel.
- Smart quotes and hidden byte-order marks from pasting through a word processor.
- Unescaped control characters inside strings — often from machine-generated data.
Format or minify?
Format when a human needs to read the payload: configs, fixtures, test data. Minify when it's going over the wire or into storage and whitespace is pure cost. Minifying never changes the data — it only removes insignificant whitespace.
One caution from experience: a 50 MB JSON document fully indented can freeze a browser tab. For files that size, use jq on the command line and keep the browser for inspecting smaller pieces.
Security: JSON is data, not code
Don't paste secrets into random online formatters. API keys, tokens and customer data are exactly what attackers hope to find in paste sites and logs. Our formatter runs locally, so the payload isn't transmitted — but the habit I'd teach is to redact secrets before sharing a payload with anyone, including tools.
And never evaluate JSON with eval() or new Function(). JSON.parse is the correct parser precisely because it cannot execute code.
The workflow I actually use
- Read the first error, not the last. Later errors are usually casualties of the first one.
- Fix syntax, then format to see the structure clearly.
- Collapse big arrays to find the object you care about.
- Minify only after validation passes.
- Keep the original payload around until the receiving end accepts the result.
Put it into practice
JSON Formatter & Validator
Format, validate and minify JSON with precise error messages — parsed entirely in your browser, so tokens and secrets in payloads stay on…
Runs in your browserJSON Validator
Check any JSON for syntax errors with the exact failure position, plus a structure summary: objects, arrays, keys, leaf values and nestin…
Runs in your browserJSON Minifier
Strip every unnecessary byte from JSON — whitespace and indentation only, structure untouched — with a before/after size comparison.
Runs in your browserJSON to TypeScript
Paste JSON and generate TypeScript interfaces: nested objects become their own interfaces, keys missing from some array items become opti…
Runs in your browserOther guides
- How to merge PDFs without uploading them6 min · 17 November 2026
- OCR a scanned PDF: accuracy, limits and privacy7 min · 17 November 2026
- Compress a PDF without destroying readability6 min · 17 November 2026