Invalid JSON is one of the most frustrating errors a developer can encounter — especially when you're working with API responses, config files, or data pipelines. The good news: JSON syntax errors are almost always caused by a handful of predictable mistakes, and they're quick to fix once you know what to look for.
This guide walks you through the most common JSON errors, what causes them, and exactly how to repair them. You can also use JSONStudio's free JSON Validator to detect and highlight errors in real-time.
Fix Invalid JSON top placement
Advertisement placeholder -- this space is reserved for contextual ads once the site is approved.
How to Read a JSON Error Message
Most parsers tell you exactly where the problem is. For example:
SyntaxError: Unexpected token '}' at position 42
This tells you there's a syntax issue near character 42. Paste your JSON into the JSONStudio Validator to get the precise line and column highlighted.
Error 1: Trailing Commas
This is the #1 most common JSON error. Unlike JavaScript objects, JSON does not allow a comma after the last item in an array or object.
// ❌ Invalid JSON — trailing comma
{
"name": "Alice",
"age": 30,
}
// ✅ Fixed — remove the last comma
{
"name": "Alice",
"age": 30
}How to fix it: Remove any comma that appears before a closing } or ].
Error 2: Single Quotes Instead of Double Quotes
JSON requires all strings — including keys — to use double quotes. Single quotes are not valid JSON, even though they are valid in JavaScript.
// ❌ Invalid JSON — single quotes
{'name': 'Alice', 'age': 30}
// ✅ Fixed — use double quotes
{"name": "Alice", "age": 30}How to fix it: Find and replace all ' with " in the JSON body. Be careful with apostrophes inside string values — they need to be escaped as \' in some contexts.
Fix Invalid JSON mid placement
Advertisement placeholder -- this space is reserved for contextual ads once the site is approved.
Error 3: Missing or Extra Commas Between Items
Every element in a JSON array or object must be separated by a comma — but only between items, not after the last one.
// ❌ Invalid — missing comma
{"name": "Alice" "age": 30}
// ✅ Fixed
{"name": "Alice", "age": 30}Error 4: Unescaped Special Characters
Certain characters inside JSON strings must be escaped with a backslash \. The most common culprits are:
\"— double quote inside a string\\— backslash\n— newline\t— tab\r— carriage return
// ❌ Invalid — unescaped double quote
{"message": "She said "hello" to me"}
// ✅ Fixed
{"message": "She said \"hello\" to me"}Error 5: Comments in JSON
JSON does not support comments. If you have copied JSON from a JavaScript file that includes // comments or /* block comments */, you must remove them before the JSON can be parsed.
// ❌ Invalid JSON — comments are not allowed
{
// User configuration
"theme": "dark",
"language": "en"
}
// ✅ Fixed — remove all comments
{
"theme": "dark",
"language": "en"
}Error 6: Invalid Number Formats
JSON has strict rules for numbers. The following formats are not valid:
- Leading zeros:
007→ must be7 - Numbers starting with
+:+5→ must be5 Infinity,NaN— not valid JSON values
The Fastest Way to Find and Fix JSON Errors
Instead of scanning your JSON manually, use a dedicated JSON repair tool:
- Open JSONStudio's JSON Validator
- Paste your invalid JSON
- The validator highlights the exact line and column of the error with a clear error message
- Fix the error and the validator updates in real-time
- Once valid, click Format in the JSON Formatter to clean up the output
Summary: JSON Error Cheat Sheet
| Error | Fix |
|---|---|
| Trailing comma | Remove comma before } or ] |
| Single quotes | Replace all ' with " |
| Missing comma | Add , between every item |
| Unescaped characters | Add \ before ", \, etc. |
| Comments | Remove all // ... and /* ... */ |
| Invalid numbers | Remove leading zeros, + signs |
Continue learning
Common JSON Errors & Fixes
Review the error messages you will encounter most, what they actually mean, and the fastest ways to fix them.
Jan 8, 2025 · 12 min read
JSON Validation Guide
From lightweight linting to full JSON Schema enforcement, this guide shows how to defend against breaking changes.
Jan 9, 2025 · 12 min read
JSON Schema Tutorial: Validate Your JSON
A hands-on tutorial for writing JSON Schema from scratch — validate API payloads, config files, and data structures.
Feb 15, 2025 · 12 min read