7 JSON Mistakes That Will Drive You Crazy
We've all been there — you paste a block of JSON into your editor, hit "Format", and get a cryptic error message. After years of working with JSON in APIs and config files, I've noticed the same handful of mistakes come up again and again. Let's walk through them so you can spot and fix them in seconds.
1. The Sneaky Trailing Comma
If you're coming from JavaScript, this one bites hard. A comma after the last property looks harmless, but JSON chokes on it immediately. It's the single most common error I see in practice.
2. Single Quotes Won't Work
JavaScript lets you get away with single quotes everywhere. JSON doesn't. Every key and every string value must use double quotes — no exceptions. If your editor auto-converts quotes, double-check your JSON output.
3. Bare Keys (No Quotes at All)
In a JS object, you can write `{ name: "Alice" }` and it works fine. In JSON, that's invalid. Keys must always be quoted strings. I've debugged this exact issue in production configs more times than I'd like to admit.
4. Trailing Commas in Arrays
Same deal as objects — arrays don't tolerate trailing commas either. It's a common pattern when you're programmatically building JSON and forget to strip the last comma.
5. Mismatched Brackets
This one gets worse as your JSON grows. A missing closing bracket deep in a nested structure can be a nightmare to find manually. Pro tip: most editors will highlight matching brackets when you click on one.
6. Unescaped Quotes Inside Strings
Try storing the text `He said "hello"` as a JSON value without escaping — it breaks the parser because it thinks the string ends at the inner quote. The fix is straightforward: use `\"` for literal double quotes.
7. Using JS-Only Values
JSON doesn't recognize `undefined`, `NaN`, `Infinity`, or comments. I've seen developers copy-paste JS objects directly into JSON and wonder why nothing works. Remember: JSON is a subset of JS, not the other way around.
Quick Fix
Still stuck? Drop your JSON into our formatter — it pinpoints the exact line and character where things went wrong, so you don't have to squint at the raw text.
JSON Formatter