Useful when comparing two documents line by line. Key order carries no meaning in JSON, so sorting is safe.
Tip: the error message points to a line and column, so you can jump straight to the typo instead of hunting for it.
Not sure what to paste? .
JSON borrows its looks from JavaScript object literals and almost none of their leniency. That resemblance is the entire cause of the problem: everything you habitually do when writing a JavaScript object is illegal in a JSON document, and the parser stops at the first one it meets.
| Message you see | What it means | Fix |
|---|---|---|
| Unexpected token } | A trailing comma before a closing brace or bracket | Delete the comma |
| Unexpected token ' | Single quotes used for a string or a key | JSON requires double quotes for both |
| Unexpected token n or u | An unquoted key, or the literals NaN / undefined | Quote the key; neither literal exists in JSON |
| Unexpected end of JSON input | A missing closing brace, bracket or quote | Balance the pairs |
They are the same operation with different whitespace, and choosing wrongly is a common source of confusion. Formatting inserts line breaks and indentation so a person can see the shape of the document; the payload grows by the size of that whitespace. Minifying removes every optional space and newline, which is what you want for a request body, a stored configuration value or anything being counted in bytes. Neither one changes a value, a key or a type — the parsed data is identical.