JSON debugging reference

JSON Errors: Syntax Errors, Parse Errors & How to Fix Them

Getting a JSON syntax error or JSON parse error? Match the parser message below to its cause, compare invalid and corrected JSON examples, and use the linked validator or repair tool to verify the fix.

How to debug a JSON error

First validate the payload, then inspect the reported line or character, repair the malformed syntax, and validate again. Remember that a parser often reports where it became stuck rather than where the original mistake began.

Common JSON errors and parser messages

Choose the error closest to the message or malformed syntax you are seeing.

JSON error

JSON Unexpected Token Error

SyntaxError: Unexpected token ... in JSON at position ...

An unexpected token error means the parser reached a character that is not legal at that point in the JSON grammar. The character may be wrong itself, or an earlier missing comma, quote, brace, or bracket may have shifted the parser out of position.

Cause, example and fix →
JSON error

Unexpected End of JSON Input

SyntaxError: Unexpected end of JSON input

This error means the parser reached the end of the text while it was still waiting for more JSON. The input is usually truncated, missing a closing brace or bracket, missing the end of a string, or completely empty.

Cause, example and fix →
JSON error

Trailing Comma in JSON

SyntaxError near a trailing comma before } or ]

Standard JSON does not allow a comma after the final property in an object or the final value in an array. JavaScript and several JSON-like formats permit trailing commas, which makes this one of the most common copy-and-paste failures.

Cause, example and fix →
JSON error

Single Quotes in JSON

SyntaxError caused by 'single-quoted' strings

JSON requires double quotes around strings and object property names. Single quotes are valid in many programming languages but are not part of the JSON grammar.

Cause, example and fix →
JSON error

JSON Property Names Must Be Double-Quoted

SyntaxError: Expected property name or } in JSON

Unlike JavaScript object literals, JSON requires every object key to be a double-quoted string. Bare identifiers such as name, userId, or enabled are invalid JSON.

Cause, example and fix →
JSON error

Invalid Escape Character in JSON

SyntaxError: Bad escaped character / invalid escape sequence

A backslash starts an escape sequence inside a JSON string. Only a defined set of escapes is legal, so paths such as C: emp or regex patterns frequently fail when their backslashes are not escaped correctly.

Cause, example and fix →
JSON error

Comments Are Not Allowed in JSON

SyntaxError at / when JSON contains a comment

The JSON standard has no comment syntax. JavaScript-style // comments and /* block comments */ make a document invalid for strict JSON parsers.

Cause, example and fix →
JSON error

Unexpected Token < in JSON

SyntaxError: Unexpected token '<' ... is not valid JSON

A less-than sign at the beginning of a supposed JSON response usually means the body is actually HTML. Common sources are 404 pages, authentication redirects, reverse-proxy errors, framework error screens, or a server route returning markup.

Cause, example and fix →
JSON toolkit

Browse all JSON tools

Open the complete FixTools JSON toolkit for formatting, validation, repair, conversion, diffing, JSONPath testing, flattening, escaping, sorting, and developer utilities.

View JSON Tools →

JSON syntax errors vs. JSON data errors

A JSON syntax error means the text itself violates JSON grammar—for example a trailing comma, single-quoted string, missing brace or invalid escape. A payload can also be syntactically valid JSON but still contain the wrong fields, types or values for an application. That second problem requires schema or application-level validation. Start with syntax validation first: downstream checks cannot reliably run until the document parses.

Why the reported JSON error position can be misleading

Parsers report the point where they can no longer continue. A missing comma can make the next property appear invalid, an unclosed quote can move the failure far beyond the original mistake, and an HTML API response can trigger a JSON parsing exception even though the JSON parser is not the real problem. Inspect both the reported character and the syntax immediately before it.