Six JSON mistakes that trip up every developer eventually, what the cryptic parser error actually means, and the fastest way to find the real problem.
If you work with APIs, config files, or just about any modern web stack, you’ve hit a JSON parse error at some point and stared at a message like Unexpected token } in JSON at position 482. It’s accurate, and almost useless, because it tells you where the parser gave up, not what’s actually wrong.
Here are the errors that come up constantly, what they actually mean, and how to fix them.
1. Trailing commas
{
"name": "ForgeSuite",
"free": true,
}
JSON doesn’t allow a trailing comma after the last item in an object or array, unlike JavaScript object literals, which do. That comma after true will break the parse. Delete it.
2. Single quotes instead of double quotes
{'name': 'ForgeSuite'}
JSON requires double quotes for both keys and string values, always. Single quotes are a JavaScript-ism that doesn’t carry over. Swap every ' for ".
3. Unquoted keys
{name: "ForgeSuite"}
Again, valid JavaScript, not valid JSON — every key needs to be a quoted string: {"name": "ForgeSuite"}.
4. Comments
JSON has no comment syntax at all — not //, not /* */. If you’ve copied a JSON-looking config from a .jsonc file or a hand-edited example with explanatory comments left in, strip them out before parsing.
5. Using undefined or NaN
JSON supports null, but it has no concept of undefined, NaN or Infinity — those are JavaScript values with no JSON equivalent. If you’re generating JSON from JavaScript objects that might contain them, you’ll get either a silent substitution or an error depending on how you serialize.
6. Mismatched brackets and braces
The classic one-hour-into-a-deeply-nested-config-file problem: one too many or too few } or ]. These are the hardest to catch by eye, because the error often points to the end of the file, not the actual location of the problem.
Why the error position rarely helps
JSON parsers are strict by design — that’s a feature, not a flaw, because it means a JSON document either means exactly one thing or it’s invalid, with no ambiguity. But it also means the parser stops at the first token it can’t make sense of, which is often several lines past where the real mistake is (a missing comma two keys earlier, for instance, makes everything after it look wrong).
The fast way to find it
Rather than scanning by eye, paste the JSON into JSONForge and hit Format. It runs the same JSON.parse your browser uses, and when it fails, it surfaces the parser’s error message immediately next to your input — so you can jump straight to the actual problem instead of bisecting the file by hand. Because it runs entirely in your browser, you can paste real data, including anything sensitive, without it going anywhere.
Once your JSON is valid, the same tool will pretty-print it with consistent indentation, or minify it down for production — useful if you’re about to paste a sample into a bug report, a Slack thread, or a request body.