The 10 Most Common JSON Errors (and How to Spot Each One)

This post is a quick reference: a rundown of the 10 most common JSON errors, each with the typical message you’ll see in the console and a one or two line explanation. The goal here isn’t to repeat the full checklist (that’s already covered in “Why Is My JSON Invalid?”), but to give you a fast way to recognize your problem from the error message, and point you to the right post for a detailed fix.

1. Trailing comma

SyntaxError: Unexpected token } in JSON at position X

A comma left after the last item in an object or array, right before the closing bracket. The most common mistake for people coming from JavaScript, where it’s allowed.

2. Single quotes instead of double

SyntaxError: Unexpected token ' in JSON at position X

JSON requires double quotes on keys and string values, no exceptions. Single quotes are never valid.

3. Unquoted key

SyntaxError: Unexpected token X in JSON at position X

In JSON, every key must be wrapped in double quotes, even though plain JavaScript makes this optional.

4. Parsing HTML instead of JSON

SyntaxError: Unexpected token < in JSON at position 0

Usually happens when an API returns an error page (404, 500) in HTML instead of the expected JSON.

5. Parsing undefined

SyntaxError: Unexpected token u in JSON at position 0

Happens when you call JSON.parse() on a variable that hasn’t been populated yet, or that came back empty from some source.

6. Incomplete string or object

SyntaxError: Unexpected end of JSON input

A }, ], or closing quote is missing. Common in hand-built JSON or truncated API responses.

7. Extra content after the JSON

SyntaxError: Unexpected non-whitespace character after JSON at position X

Happens when there’s more than one JSON object pasted together without a separator, or extra text after the expected closing bracket.

8. Comments inside the JSON

JSON doesn’t have a specific error message for this, it usually shows up as “unexpected token” at the position of the // or /*. JSON simply doesn’t support comments, even if the tool you use daily allows them.

9. Values that only exist in JavaScript

SyntaxError: Unexpected token N in JSON at position X (for NaN)

undefined, NaN, functions, and Date objects don’t exist in JSON. The closest equivalent is null.

10. Invalid number format

Usually shows up as “unexpected token” right after the malformed number. A leading zero (01), a decimal point with no digit before (.5) or after (5.) it aren’t accepted by the JSON spec.

The fastest way to fix it, without memorizing all this

Instead of manually comparing your error message against this list, paste the JSON into JSON Formatter & Validator. It points to the exact position of the problem right away, which is usually faster than ruling out causes one by one.

Want more detail on a specific error?

Each of these has a dedicated post with code examples and step by step fixes: