Common JSON Errors and How to Fix Them

A complete guide to identifying, understanding, and fixing JSON syntax errors

Last updated: January 21, 2026 • 10 min read

Even experienced developers encounter JSON errors. This guide covers the 15 most common JSON errors, why they happen, and how to fix them quickly.

1. Missing or Extra Commas

One of the most common JSON errors is incorrect comma usage.

❌ Wrong (Missing Comma):

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

❌ Wrong (Trailing Comma):

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

✅ Correct:

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

Fix: Add commas between key-value pairs, but never after the last item.

2. Single Quotes Instead of Double Quotes

JSON requires double quotes for strings. Single quotes will cause a parse error.

❌ Wrong:

{
  'name': 'John',
  'city': 'New York'
}

✅ Correct:

{
  "name": "John",
  "city": "New York"
}

Fix: Always use double quotes (") for both keys and string values.

3. Unquoted Keys

Unlike JavaScript objects, JSON requires all keys to be strings in double quotes.

❌ Wrong:

{
  name: "John",
  age: 30
}

✅ Correct:

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

Fix: Wrap all keys in double quotes.

4. Comments in JSON

Standard JSON does not support comments. They will cause parsing to fail.

❌ Wrong:

{
  // This is a comment
  "name": "John",
  /* Multi-line
     comment */
  "age": 30
}

✅ Correct:

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

Fix: Remove all comments or use a separate documentation file.

5. Mismatched Brackets and Braces

Every opening bracket [ needs a closing ], and every opening brace { needs a closing }.

❌ Wrong:

{
  "users": [
    {"name": "John"},
    {"name": "Jane"
  ]
}

✅ Correct:

{
  "users": [
    {"name": "John"},
    {"name": "Jane"}
  ]
}

Fix: Use a JSON validator to quickly identify missing or extra brackets.

6. Undefined or NaN Values

JSON doesn't support undefined, NaN, or Infinity. Use null instead.

❌ Wrong:

{
  "value": undefined,
  "result": NaN,
  "infinity": Infinity
}

✅ Correct:

{
  "value": null,
  "result": null,
  "infinity": null
}

Fix: Replace undefined, NaN, and Infinity with null or remove the property.

7. Unescaped Special Characters

Special characters like quotes, backslashes, and newlines must be escaped in JSON strings.

❌ Wrong:

{
  "message": "She said "Hello""
}

✅ Correct:

{
  "message": "She said \"Hello\""
}

Common escape sequences:

  • \\" - Double quote
  • \\\\ - Backslash
  • \\n - Newline
  • \\t - Tab
  • \\r - Carriage return

8. Numbers as Strings

Numeric values should not be quoted unless you specifically need them as strings.

⚠️ Potentially Wrong:

{
  "age": "30",
  "price": "19.99"
}

✅ Better (if these should be numbers):

{
  "age": 30,
  "price": 19.99
}

Fix: Remove quotes from numeric values unless they need to be treated as strings (like zip codes or phone numbers).

9. Duplicate Keys

Having the same key twice in an object is technically valid JSON, but the last value wins, which can cause confusion.

⚠️ Problematic:

{
  "name": "John",
  "age": 25,
  "name": "Jane"
}

Result: name will be "Jane"

✅ Better:

{
  "firstName": "John",
  "lastName": "Jane",
  "age": 25
}

Fix: Use unique key names or restructure your data.

10. Incorrect Boolean Values

Boolean values in JSON must be lowercase true or false.

❌ Wrong:

{
  "isActive": True,
  "isDeleted": FALSE
}

✅ Correct:

{
  "isActive": true,
  "isDeleted": false
}

Fix: Use lowercase true and false without quotes.

11. Extra Whitespace or Special Characters

Invisible characters like BOM (Byte Order Mark) or non-standard whitespace can cause parsing errors.

Fix: Use a JSON formatter to normalize your JSON and remove hidden characters.

12. Mixing Array and Object Syntax

Don't mix array brackets with object braces incorrectly.

❌ Wrong:

{
  "users": {
    {"name": "John"},
    {"name": "Jane"}
  }
}

✅ Correct (Array of Objects):

{
  "users": [
    {"name": "John"},
    {"name": "Jane"}
  ]
}

13. Empty Strings as Null

Distinguish between empty strings ("") and null values.

{
  "middleName": "",     // Empty string - valid
  "nickname": null      // Null - also valid but different meaning
}

Tip: Use "" when the value exists but is empty, and null when the value doesn't exist or is unknown.

14. Incorrectly Formatted Dates

JSON doesn't have a native date type. Use ISO 8601 format strings.

✅ Good Practice:

{
  "createdAt": "2026-01-21T10:30:00Z",
  "birthDate": "1990-05-15"
}

15. File Encoding Issues

JSON files should be encoded in UTF-8. Other encodings can cause parsing errors.

Fix: Save your JSON files with UTF-8 encoding (without BOM).

Quick Debugging Tips

🔧 Debug JSON Errors Fast

  1. Use a validator: Our JSON validator shows you exactly where errors are
  2. Check line numbers: Most error messages tell you the line number
  3. Look for patterns: Errors often repeat (e.g., all single quotes)
  4. Format first: Use a formatter to make structure visible
  5. Binary search: Remove half the JSON to isolate the error

Tools for Fixing JSON Errors

Our free tools make it easy to find and fix JSON errors:

🔍 JSON Validator

Instantly find syntax errors with clear error messages

Validate JSON →

✨ JSON Formatter

Format and beautify your JSON for better readability

Format JSON →

📊 JSON Tree Viewer

Visualize JSON structure to spot issues

View Tree →

🔄 JSON Diff

Compare two JSON objects to find differences

Compare JSON →

Common Error Messages Explained

SyntaxError: Unexpected token

Usually means there's a character where it shouldn't be (extra comma, wrong quote, etc.)

SyntaxError: Unexpected end of JSON input

The JSON is incomplete - missing closing braces or brackets.

SyntaxError: Expected property name or '}'

Missing or incorrectly formatted key name in an object.

JSON Parse error: Unrecognized token

Invalid value like undefined, NaN, or unquoted string.

Prevention Best Practices

  1. Use a linter: Configure your code editor to highlight JSON errors
  2. Generate programmatically: Use JSON.stringify() instead of writing by hand
  3. Validate before using: Always validate JSON from external sources
  4. Use TypeScript/schemas: Type checking helps prevent structure errors
  5. Test with real data: Edge cases often reveal hidden errors

Conclusion

Most JSON errors are simple syntax mistakes that are easy to fix once you know what to look for. Use validation tools, follow the JSON syntax rules strictly, and you'll avoid most common pitfalls.

Fix Your JSON Errors Now

Paste your JSON and get instant error detection with helpful fix suggestions!

Validate JSON Free →