Common JSON Errors and How to Fix Them
1. Trailing Commas
The most common mistake. JavaScript allows trailing commas in objects and arrays, but JSON does not:
// ❌ Invalid — trailing comma
{ "name": "Alice", "age": 30, }
// ✅ Valid
{ "name": "Alice", "age": 30 }
2. Single Quotes Instead of Double
JSON requires double quotes for all string values and keys. Single quotes will cause a parse error:
// ❌ Invalid
{ 'name': 'Alice' }
// ✅ Valid
{ "name": "Alice" }
3. Unquoted Keys
Keys must always be quoted strings. This is not JavaScript — you cannot omit quotes on property names:
// ❌ Invalid
{ name: "Alice" }
// ✅ Valid
{ "name": "Alice" }
4. Comments in JSON
JSON does not support comments. Remove all // and /* */ blocks before parsing:
// ❌ Invalid
{
// This is a comment
"name": "Alice"
}
// ✅ Valid
{
"name": "Alice"
}
5. Mismatched Braces or Brackets
Every opening { or [ must have a matching closing pair. A missing bracket is the second most common cause of parse errors:
// ❌ Invalid — missing closing brace
{ "users": [ { "id": 1 } ]
// ✅ Valid
{ "users": [ { "id": 1 } ] }
Quick fix: Paste your JSON into a formatter. It will highlight the exact location of mismatched brackets.
6. Trailing Data After Root Value
JSON must have exactly one root value. Extra data after the closing brace causes a parse error:
// ❌ Invalid
{"name": "Alice"} {"age": 30}
// ✅ Valid
{"name": "Alice", "age": 30}
Validate and fix your JSON instantly?
Use the JSON Formatter & Validator tool