Most "Unexpected token …" and "JSON.parse" errors come from a handful of small syntax mistakes. Here's each one, why it breaks, and the fix. The fastest way to find yours: paste the JSON into the viewer — it points to the exact spot that fails.
Validate & fix my JSON →A comma after the last item is the single most common cause of Unexpected token } in JSON.
✗ {"a": 1, "b": 2,}
✓ {"a": 1, "b": 2}
JSON requires double quotes for both keys and string values. Single quotes give Unexpected token ' in JSON.
✗ {'name': 'Ada'}
✓ {"name": "Ada"}
Object keys must be quoted strings. {name: "Ada"} is valid JavaScript but invalid JSON.
✗ {name: "Ada"}
✓ {"name": "Ada"}
JSON does not allow // or /* */ comments. Remove them (or use JSON5 if your parser supports it).
✗ {"a": 1 // the first one}
✓ {"a": 1}
✗ {"a": 1 "b": 2}
✓ {"a": 1, "b": 2}
Literal newlines, tabs, or unescaped double quotes inside a string are invalid. Escape them with a backslash.
✗ {"msg": "She said "hi""}
✓ {"msg": "She said \"hi\""}
A JSON document must be a single value. A variable assignment, an anti-hijacking prefix like )]}',, or a stray character at the end all cause parse errors. Keep only the JSON itself.
✗ var data = {"a": 1};
✓ {"a": 1}
JSON has no NaN, Infinity, undefined, leading zeros (007), or trailing decimal points. Use a valid number, a quoted string, or null.
✗ {"x": NaN, "y": 007, "z": undefined}
✓ {"x": null, "y": 7, "z": null}
Rather than hunting by eye, paste your JSON into the free JSON viewer: it validates as you paste, reports the first error, and renders the rest as a collapsible tree so you can see where the structure breaks — even for large files. Nothing is uploaded; it all runs in your browser.
Open the JSON viewer →