JSONPretty
JSON Formatter & Validator
Paste JSON — pretty-print it, minify it, or get a clear syntax error showing what went wrong.
Common JSON syntax errors and what causes them
JSON is far stricter than JavaScript object literals. These are the errors that account for most parse failures.
| Error message | Cause | Fix |
|---|---|---|
| Unexpected token } in JSON | Trailing comma after the last item | Remove the comma before } or ] |
| Unexpected token ' in JSON | Single-quoted strings | JSON requires double quotes |
| Unexpected token n in JSON | Unquoted key, or a stray NaN | Quote every key; NaN is not valid JSON |
| Unexpected end of JSON input | Truncated data or an unclosed bracket | Check every { and [ has a partner |
| Unexpected token in JSON at position 0 | Empty body, or HTML returned instead of JSON | Check the response is actually JSON |
| Bad control character in string | A literal newline or tab inside a string | Escape them as backslash-n and backslash-t |
JSON has no comments, no trailing commas, no single quotes, and no undefined or NaN values. Keys must always be double-quoted strings.
Strict JSON rules
Keys must be double-quoted strings. No trailing commas. No comments. No single quotes. JavaScript object literals are not JSON — `JSON.parse` rejects them.
Frequently asked questions
My API response is one long line — how do I read it?
Paste the minified JSON into this formatter and it will pretty-print it with proper indentation. Most APIs return compact JSON to save bandwidth, which is valid but unreadable without formatting.
What's the difference between JSON and a JavaScript object?
JSON requires double-quoted keys, no trailing commas, no comments, and no undefined values. A JavaScript object literal allows all of those. JSON.parse() rejects anything that isn't strict JSON.
Why does my JSON have a 'trailing comma' error?
JSON does not allow a comma after the last item in an array or object. While JavaScript tolerates trailing commas, JSON strictly forbids them. Remove the comma before any closing ] or }.
Is there a size limit for JSON files?
The JSON specification has no size limit, but practical limits come from the parser. Browsers typically handle up to ~500 MB, and most API gateways cap request bodies at 1-10 MB.
Related Developer calculators
Last updated: September 7, 2026