10 Most Common JSON Errors and How to Fix Them

JSON syntax errors can be frustrating and time-consuming to debug. Even experienced developers make these mistakes. This guide covers the 10 most common JSON errors, with examples and solutions to help you fix them quickly.

1. Missing or Extra Commas

Error: Objects and arrays require commas between elements, but not after the last element.

Incorrect:

{
  "name": "John",
  "age": 30,
}

Correct:

{
  "name": "John",
  "age": 30
}

2. Unquoted Object Keys

Error: All object keys must be strings enclosed in double quotes.

Incorrect:

{
  name: "John",
  age: 30
}

Correct:

{
  "name": "John",
  "age": 30
}

3. Invalid String Escaping

Error: Special characters in strings must be properly escaped.

Incorrect:

{
  "message": "Hello "World"!"
}

Correct:

{
  "message": "Hello \"World\"!"
}

4. Mismatched Brackets

Error: Every opening bracket must have a corresponding closing bracket.

Incorrect:

{
  "items": ["apple", "banana"
}

Correct:

{
  "items": ["apple", "banana"]
}

5. Trailing Commas

Error: JSON doesn't allow commas after the last item in objects or arrays.

Incorrect:

{
  "name": "John",
  "age": 30,
}

Correct:

{
  "name": "John",
  "age": 30
}

6. Invalid Number Format

Error: Numbers cannot have leading zeros (except for 0) and must follow JavaScript number syntax.

Incorrect:

{
  "price": 099.99,
  "version": 1.2.3
}

Correct:

{
  "price": 99.99,
  "version": "1.2.3"
}

7. Single Quotes Instead of Double Quotes

Error: JSON only accepts double quotes for strings and keys.

Incorrect:

{
  'name': 'John',
  "age": 30
}

Correct:

{
  "name": "John",
  "age": 30
}

8. Comments in JSON

Error: JSON doesn't support comments. Remove all comments before parsing.

Incorrect:

{
  // This is a comment
  "name": "John",
  "age": 30
}

Correct:

{
  "name": "John",
  "age": 30
}

9. Invalid Boolean Values

Error: Boolean values must be lowercase "true" or "false".

Incorrect:

{
  "active": True,
  "disabled": FALSE
}

Correct:

{
  "active": true,
  "disabled": false
}

10. Null Value Issues

Error: The null value must be lowercase.

Incorrect:

{
  "middleName": NULL,
  "spouse": none
}

Correct:

{
  "middleName": null,
  "spouse": null
}

How JSONLintPlus Helps

JSONLintPlus catches all these errors instantly with:

  • Precise error location (line and column numbers)
  • Clear, actionable error messages
  • Real-time validation as you type
  • Automatic error highlighting

Prevention Tips

  • Use a JSON validator during development
  • Enable syntax highlighting in your code editor
  • Use JSON Schema for complex data structures
  • Test your JSON with multiple parsers
  • Use linters that check for common JSON issues

Conclusion

Most JSON errors follow common patterns that are easy to spot once you know what to look for. By understanding these 10 most common errors and using tools like JSONLintPlus, you can significantly reduce debugging time and prevent JSON-related issues in your applications.

Remember: when in doubt, validate your JSON!