Common JSON errors (and their fixes)

JSON looks like JavaScript, but it is a much stricter format — and that gap is where almost every "Unexpected token" error comes from. Here are the classics, with fixes.

1. Trailing comma

❌ Invalid{"a": 1, "b": 2,}
✓ Valid{"a": 1, "b": 2}

JavaScript objects tolerate a comma after the last item; JSON never does. The #1 error by far.

2. Single quotes

❌ Invalid{'name': 'Alice'}
✓ Valid{"name": "Alice"}

JSON strings and keys must use double quotes. Always.

3. Unquoted keys

❌ Invalid{name: "Alice"}
✓ Valid{"name": "Alice"}

4. Comments

JSON has no comments — // and /* */ are both syntax errors. If your config format allows comments (like tsconfig.json), that's JSONC, a different format that a strict parser will reject.

5. NaN, Infinity, undefined

None of these exist in JSON. Numbers must be finite literals; missing values must be null. JSON.stringify silently converts NaN to null — a favorite source of confusing bugs.

6. Unescaped characters in strings

Literal newlines and tabs inside a string must be written \n and \t; double quotes inside a string must be \". Windows paths need doubled backslashes: "C:\\Users\\me".

7. Multiple root values

A JSON document is exactly one value. Two objects back-to-back ({}{}) or newline-delimited records are NDJSON — parse each line separately.

Find yours in seconds

Paste the failing JSON into the formatter on the home page — it reports the exact line and column where parsing stopped, which is almost always where (or just after) the mistake sits.