{}JSON FYI

Common JSON errors and how to fix them

Every common JSON error mapped to its cause and fix — trailing commas, single quotes, 'Unexpected token', JSONDecodeError — each with a dedicated guide.

·9 min read

What causes most JSON errors?

Nearly every JSON parse failure comes from one of a few mistakes — a trailing comma, single quotes, an unquoted key, a comment, or a response that wasn't JSON at all (an HTML error page, an empty body). The parser reports the first character it can't accept, with a line and column. This guide maps every common error message to its cause and its fix, and links a focused walkthrough for each.

Read the error messageAt position 0the body isn't JSONUnexpected token '<'Partway througha syntax mistakeUnexpected token }At the endtruncated / unbalancedUnexpected end of inputOn stringifycan't be serializedcircular structureSame mistake, different wording across languages — match yours below.

Match the error message to its fix

Parsers phrase the same underlying mistake differently across languages. Find the message you're seeing and jump to the guide that fixes it.

JavaScript · JSON.parse()

Python · json.loads() / json.load()

Databases · PostgreSQL

The mistakes behind most syntax errors

Whatever the message, the underlying cause is usually one of these. Each is invalid JSON even though it looks fine at a glance.

1. Trailing commas

{ "a": 1, "b": 2, }   // ✗ invalid
{ "a": 1, "b": 2 }    // ✓

The single most common JSON error. See trailing commas in JSON for why every strict parser rejects them and how JSON5/JSONC differ.

2. Single-quoted strings

{ 'name': 'Ada' }     // ✗ invalid (single quotes)
{ "name": "Ada" }     // ✓

3. Unquoted keys

{ name: "Ada" }       // ✗ invalid (unquoted key)
{ "name": "Ada" }     // ✓

4. JavaScript-style comments

{ "a": 1 /* note */ } // ✗ invalid — JSON has no comments
{ "a": 1, "_note": "..." } // ✓ use a sibling field

JSON has no comment syntax at all. See JSON comments for five practical workarounds.

5. Wrong literals

{ "ok": True, "x": None } // ✗ Python literals
{ "ok": true, "x": null } // ✓

6. Unescaped control characters

Real newlines and tabs inside strings are illegal — escape them: \\n, \\t. See how to escape characters in JSON for the complete table.

7. Duplicate keys

{ "id": 1, "id": 2 }  // ⚠ legal but unpredictable

RFC 8259 says names should be unique, so duplicates parse but most parsers silently keep the last value. See are duplicate keys valid in JSON? for what each parser does.

8. Numeric oddities

  • No leading zeros: 007 is invalid. Use 7.
  • No NaN, Infinity, or undefined — use null when you mean "no value".
  • No hexadecimal: 0xFF is invalid.

Find the exact character

The fastest way to locate any of these is to paste the document into a validator that reports the precise line and column. If you'd rather see structural problems — trailing commas, duplicate keys, comments — flagged as warnings, use the JSON linter. To confirm the shape of your data against required fields and types, use the JSON Schema validator. New to the format? Start with what is JSON and the data types reference.

Paste your JSON into the validator →

Get the exact line, column, and a fix hint in seconds — no upload, no signup.

Open JSON Validator →

Frequently asked questions

Why does my JSON validator say 'unexpected token'?+

It hit a character it didn't expect at that position — usually a stray comma, missing quote, or unquoted identifier. The line and column in the message tell you where to look.

What is the most common JSON error?+

A trailing comma — a comma after the last element of an object or array. It is valid in JavaScript and Python source but rejected by every strict JSON parser.

Why does my parser say 'Unexpected token <' at position 0?+

The server returned an HTML page (often a 404 or 500 error page) instead of JSON, and the parser is choking on the opening '<' of a tag. Check the response status and Content-Type before parsing.

Are duplicate keys an error?+

RFC 8259 says object names should be unique but does not forbid duplicates, so the document parses. Behavior is unpredictable — most parsers keep the last value. Treat duplicates as a bug; the JSON FYI linter warns about them.

How do I find which line and column my JSON error is on?+

Paste the document into a validator — JSON FYI reports the exact line, column, and a fix hint. Most language parsers also expose the position: Python's JSONDecodeError has .lineno, .colno, and .pos; JavaScript embeds the position in the message.

Related tools & guides