Common JSON Errors and How to Fix Them

Troubleshoot and fix the most frequent JSON parsing errors with clear examples and solutions.

Quick fix: Paste your JSON into our JSON Formatter - it automatically fixes many common errors like trailing commas and single quotes.

1. Trailing Comma

A comma after the last item in an object or array is not allowed in JSON.

Wrong
{
  "name": "John",
  "age": 30,  // Error: trailing comma
}
Correct
{
  "name": "John",
  "age": 30
}

Fix: Remove the comma after the last property or array element.

2. Single Quotes Instead of Double Quotes

JSON requires double quotes for strings. Single quotes are not valid.

Wrong
{
  'name': 'John'  // Error: single quotes
}
Correct
{
  "name": "John"
}

Fix: Always use double quotes (") for strings and keys in JSON.

3. Unquoted Keys

All keys in JSON must be strings enclosed in double quotes.

Wrong
{
  name: "John"  // Error: unquoted key
}
Correct
{
  "name": "John"
}

Fix: Wrap all object keys in double quotes.

4. Missing Comma Between Items

Each item in an object or array must be separated by a comma.

Wrong
{
  "name": "John"
  "age": 30  // Error: missing comma
}
Correct
{
  "name": "John",
  "age": 30
}

Fix: Add commas between all items except after the last one.

5. Comments in JSON

Standard JSON does not support comments. They will cause parse errors.

Wrong
{
  "name": "John",
  // This is a comment - NOT ALLOWED
  "age": 30
}
Correct
{
  "name": "John",
  "age": 30
}

Fix: Remove all comments from JSON. Use a separate documentation file if needed.

6. Undefined or NaN Values

JSON only supports null, not undefined or NaN.

Wrong
{
  "value": undefined,  // Error
  "number": NaN        // Error
}
Correct
{
  "value": null,
  "number": 0
}

Fix: Use null instead of undefined. Replace NaN with a valid number or null.

7. Unclosed Brackets or Braces

Every opening bracket must have a matching closing bracket.

Wrong
{
  "items": [1, 2, 3
}
Correct
{
  "items": [1, 2, 3]
}

Fix: Check that all { } and [ ] brackets are properly matched and closed.

8. Invalid Escape Sequences

Backslashes must be properly escaped in strings.

Wrong
{
  "path": "C:\Users\name"  // May cause issues
}
Correct
{
  "path": "C:\\Users\\name"
}

Fix: Use double backslashes (\\) or forward slashes (/) in paths.

Quick Reference

  • • Always use double quotes for strings and keys
  • • No trailing commas after the last item
  • • No comments in JSON
  • • Match all brackets and braces
  • • Use null instead of undefined
  • • Escape special characters properly

Validate Your JSON Now

Our JSON formatter automatically detects and fixes common errors.

Open JSON Formatter