Trailing commas, single quotes and the rest of the usual suspects
JSON is a small, strict format, which is exactly why it is reliable and exactly why tiny deviations break parsers. The same handful of mistakes accounts for nearly every "unexpected token" message. Here is the list, with the fix for each.
A comma after the last item of an object or array is legal in JavaScript and illegal in JSON. It is the most common cause of a parse failure, especially in hand-edited config files. Delete the final comma before the closing brace or bracket.
JSON strings must use double quotes. Single-quoted values and keys are JavaScript habits. A bulk replacement works, but check for apostrophes inside strings first — they will need escaping or different quoting.
{"name": "x"} is valid; {name: "x"} is not. Every object key must be a double-quoted string. This breaks most often when someone copies an object literal from source code.
JSON has no comment syntax. // and /* */ are invalid, which is why some configuration formats extend JSON to allow them. Remove comments before parsing, or move notes into a dedicated field such as "_comment".
None of these are JSON values. Use null, or represent the value as a string or a sentinel number. JavaScript's JSON.stringify silently converts NaN and Infinity to null, which is why the bug sometimes appears only at the receiver.
01, 1. and 1,000 are invalid. JSON numbers have a strict grammar: no leading zeros, no thousands separators, no currency symbols, no trailing decimal point. Quote them as strings if they are identifiers such as phone numbers or PIN codes.
A literal newline inside a string breaks parsing — use \n. A double quote inside a string must be escaped as \". Windows paths need doubled backslashes. These appear most often in pasted log lines and error messages.
The spec allows the text but not the semantics: behaviour is undefined and most parsers keep the last value. Validators and linters flag it; treat any duplicate as a bug because the losing value silently disappears.
A UTF-8 byte-order mark at the start of a file, or non-breaking spaces copied from a document, will fail parsing with an error that points at the wrong place. Paste into a plain-text editor or the JSON formatter and look for the first unexpected character.
"Unexpected end of input" usually means the payload was cut off — a truncated API response, a partial file write, or a proxy with a size limit. Validate the length before blaming the syntax.
See also the JSON formatter guide and pretty-printing API responses.
The usual causes are a trailing comma, single quotes, unquoted keys, comments, or a value like NaN or undefined. Validate to get the position, then fix the first error and re-check.
No. JSON has no comment syntax, so // and /* */ make the document invalid. Some config formats extend JSON to permit them, but strict parsers reject them.
The text may parse but behaviour is undefined and most parsers keep the last value, silently dropping the first. Treat duplicates as a bug.
No. Formatting, minifying and validation run in your browser, so your data never leaves your device.