5 Common JSON Errors and How to Fix Them
Published: May 25, 2025 · 5 min read
Every developer has seen the dreaded "Unexpected token" or "JSON.parse error" message. JSON has strict syntax rules, and even a tiny mistake breaks the entire document. Here are the 5 most common errors and exactly how to fix each one.
Error 1: Trailing Commas
The most common JSON error. JavaScript allows trailing commas, but JSON does not.
❌ Invalid:
✅ Fixed:
Rule: The last item in an object or array must NOT have a comma after it.
Error 2: Single Quotes
JSON requires double quotes for all strings and keys. Single quotes are not valid.
❌ Invalid:
✅ Fixed:
Rule: Always use double quotes (") for both keys and string values. Never single quotes (').
Error 3: Unquoted Keys
In JavaScript objects, keys don't need quotes. In JSON, they always do.
❌ Invalid:
✅ Fixed:
Rule: Every key in JSON must be a double-quoted string.
Error 4: Missing Commas
Forgetting a comma between properties is easy to do, especially in multi-line JSON.
❌ Invalid:
✅ Fixed:
Rule: Every key-value pair must be followed by a comma, except the last one.
Error 5: Unmatched Brackets
Opening a bracket or brace without closing it — or closing one that was never opened.
❌ Invalid:
✅ Fixed:
Rule: Every { needs a matching }, and every [ needs a matching ]. Use an editor with bracket matching to spot these quickly.
How to Fix JSON Automatically
Don't want to hunt for errors manually? Our Auto-Fix JSON tool detects and repairs all five of these errors automatically. Just paste your broken JSON and click "Fix" — the tool shows you exactly what it repaired.
You can also use our JSON Formatter & Validator to pinpoint the exact line and character where an error occurs, making manual fixes easy.
Prevention Tips
- Use an editor with JSON syntax highlighting (VS Code, Sublime Text)
- Enable auto-format on save in your IDE
- Validate JSON before sending it to an API
- Use TypeScript or schema validation to catch errors at compile time
- Never manually edit minified JSON — format it first, edit, then minify