JSON errors can be frustrating, especially when error messages aren't clear. Here are the 10 most common JSON errors and how to fix them.
1. Trailing Commas
// ❌ Wrong
{"name": "Alice",}
// ✅ Correct
{"name": "Alice"}
2. Single Quotes Instead of Double Quotes
// ❌ Wrong
{'name': 'Alice'}
// ✅ Correct
{"name": "Alice"}
3. Unquoted Keys
// ❌ Wrong
{name: "Alice"}
// ✅ Correct
{"name": "Alice"}
4. Comments in JSON
// ❌ Wrong — JSON doesn't support comments
{"name": "Alice" /* user name */}
// ✅ Use JSONC or remove comments
5. Undefined Values
JSON only supports null, not undefined. Omit the key or use null.
6. Hexadecimal Numbers
// ❌ Wrong
{"color": 0xFFFFFF}
// ✅ Correct
{"color": "#FFFFFF"}
7. Missing Commas Between Elements
8. Extra Commas (two commas in a row)
9. Unclosed Brackets or Braces
10. Invalid Escape Sequences
Use our JSON Validator to catch these errors with precise line and column numbers.