← Back to Blog
Debugging

10 Common JSON Errors and How to Fix Them

Published January 2026 • 7 min read

JSON is strict about its syntax. A single misplaced comma or missing quote can break an entire parse operation. Here are the ten most common JSON errors, what causes them, and exactly how to fix each one.

1. Trailing Comma

One of the most frequent mistakes — especially for developers coming from JavaScript, which allows trailing commas in arrays and objects.

Error
{ "name": "Dinesh", "city": "Chennai", }
Fix
{ "name": "Dinesh", "city": "Chennai" }

2. Single Quotes Instead of Double Quotes

JSON requires double quotes for both keys and string values. Single quotes are not valid.

Error
{ 'name': 'Dinesh' }
Fix
{ "name": "Dinesh" }

3. Unquoted Keys

Unlike JavaScript objects, JSON keys must always be strings enclosed in double quotes.

Error
{ name: "Dinesh" }
Fix
{ "name": "Dinesh" }

4. Comments in JSON

JSON does not support comments. Many developers try to add them — this will always cause a parse error.

Error
{ // user info
  "name": "Dinesh" }
Fix
{ "name": "Dinesh" }

5. Missing Comma Between Properties

Every property in an object and every item in an array must be separated by a comma.

Error
{ "name": "Dinesh" "city": "Chennai" }
Fix
{ "name": "Dinesh", "city": "Chennai" }

6. Mismatched Brackets or Braces

Every opening { or [ must have a matching closing } or ].

Error
{ "items": [1, 2, 3 }
Fix
{ "items": [1, 2, 3] }

7. Undefined or NaN Values

JSON only accepts null, not JavaScript-specific values like undefined, NaN, or Infinity.

Error
{ "value": undefined }
Fix
{ "value": null }

8. Unescaped Special Characters in Strings

Certain characters inside strings must be escaped with a backslash: \", \\, \n, \t, etc.

Error
{ "message": "He said "hello"" }
Fix
{ "message": "He said \"hello\"" }

9. Number as Object Key

Keys must always be strings. Using a bare number as a key is not valid JSON.

Error
{ 1: "first", 2: "second" }
Fix
{ "1": "first", "2": "second" }

10. Extra Data After the Root Element

A valid JSON document has exactly one root element. Having extra characters after it will cause a parse failure.

Error
{ "name": "Dinesh" } { "city": "Chennai" }
Fix
[ { "name": "Dinesh" }, { "city": "Chennai" } ]

If you are struggling to find the error in your JSON, paste it into the JSON formatter tool — it will show you exactly where the parse error occurs.