WebToolsPlanet
JSON Debugging Cheat Sheet

Common JSON Errors: Examples, Causes and Fixes

Search a parser message, compare broken and valid JSON, and open the exact example in a validator.

Validate my JSON

18 examples · Verified with Node.js 24.18.0 · Last reviewed 2026-07-10

Every example is minimal and runnable. Most are syntax errors; duplicate keys and wrong data shapes show why valid JSON can still break an application. Parser wording varies by runtime, so this guide identifies the environment used for verification.

Find your JSON error

Search a verified parser message or narrow the guide by context.

18 of 18 shown

Category

Difficulty

Quick JSON error reference

Scan all 18 errors, then jump to the full explanation.

Free resource by WebToolsPlanet · webtoolsplanet.com/cheat-sheets/json-errors

JSON error examples and fixes

Open an example to compare the broken input, parser result, cause, and correction.

Quotes, Keys and Commas

5 matching examples

BeginnerSyntax error

Trailing Comma in JSON: Expected Property Name

Expected double-quoted property name in JSON at position 26

The parser found a comma after the final object property, where it expected another quoted property name.

Broken JSON

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

Highlighted error location: line 1, column 27 · position 26

Parser result

Expected double-quoted property name in JSON at position 26

Older V8/Node versions report "Unexpected token } in JSON at position 26" for the same error.

Why it happens: RFC 8259 does not allow a comma after the last property or array element. JavaScript literals may tolerate it, but strict JSON does not.

Corrected JSON

{"name": "Ana", "age": 30}
BeginnerSyntax error

Expected Property Name: Add Double Quotes Around JSON Keys

Expected property name or '}' in JSON at position 1

JSON object keys must be strings wrapped in double quotes; bare identifiers such as name are invalid.

Broken JSON

{name: "Ana", age: 30}

Highlighted error location: line 1, column 2 · position 1

Parser result

Expected property name or '}' in JSON at position 1

Why it happens: Unquoted identifiers are valid in JavaScript object literals, but JSON requires every object member name to be a double-quoted string.

Corrected JSON

{"name": "Ana", "age": 30}
BeginnerSyntax error

Single Quotes Are Not Valid JSON Strings

Expected property name or '}' in JSON at position 1

Strict JSON accepts double-quoted strings only, so the first single quote stops parsing immediately.

Broken JSON

{'name': 'Ana', 'age': 30}

Highlighted error location: line 1, column 2 · position 1

Parser result

Expected property name or '}' in JSON at position 1

Why it happens: Single quotes are valid in JavaScript and Python, but they are not part of the JSON string grammar.

Corrected JSON

{"name": "Ana", "age": 30}
BeginnerSyntax error

Expected a Comma After a JSON Property Value

Expected ',' or '}' after property value in JSON at position 15

The parser completed one property value and found the next key without the required comma separator.

Broken JSON

{"name": "Ana" "age": 30}

Highlighted error location: line 1, column 16 · position 15

Parser result

Expected ',' or '}' after property value in JSON at position 15

Why it happens: Every object property and array element must be comma-separated. Parsers do not infer a boundary from whitespace or a line break.

Corrected JSON

{"name": "Ana", "age": 30}
BeginnerSyntax error

Comments Are Not Valid JSON: Expected Property Name

Expected property name or '}' in JSON at position 4

Strict JSON has no comment syntax, so a parser rejects the first slash in // or /* */.

Broken JSON

{
  // the user's display name
  "name": "Ana"
}

Highlighted error location: line 2, column 3 · position 4

Parser result

Expected property name or '}' in JSON at position 4

Why it happens: JSONC files such as VS Code settings may allow comments, but JSON.parse and strict RFC 8259 parsers do not.

Corrected JSON

{
  "name": "Ana"
}

Brackets and Nesting

3 matching examples

IntermediateSyntax error

Unexpected End of JSON Input: Missing Bracket or Brace

Expected ',' or '}' after property value in JSON at position 19

“Unexpected end of JSON input” means parsing reached the end before receiving one complete value. Here, the outer object never closes.

Broken JSON

{"items": [1, 2, 3]

Parser result

Expected ',' or '}' after property value in JSON at position 19

Why it happens: Every opening { or [ requires a matching close before the JSON document ends.

Corrected JSON

{"items": [1, 2, 3]}
IntermediateSyntax error

Unexpected Content After JSON: Extra Closing Brace

Unexpected non-whitespace character after JSON at position 20

The JSON value is already complete, so the final unmatched brace is treated as invalid trailing content.

Broken JSON

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

Highlighted error location: line 1, column 21 · position 20

Parser result

Unexpected non-whitespace character after JSON at position 20

Why it happens: A JSON document contains exactly one top-level value followed only by optional whitespace.

Corrected JSON

{"items": [1, 2, 3]}
IntermediateSyntax error

Unexpected Token Colon: Object Fields Placed Inside an Array

Expected ',' or ']' after array element in JSON at position 16

Arrays contain values, not key-value members, so a colon cannot follow an array string unless that string sits inside an object.

Broken JSON

{"user": ["name": "Ana"]}

Highlighted error location: line 1, column 17 · position 16

Parser result

Expected ',' or ']' after array element in JSON at position 16

Why it happens: A "key": value member is legal only inside an object. Arrays hold an ordered sequence of values.

Corrected JSON

{"user": {"name": "Ana"}}

Strings and Escaping

2 matching examples

IntermediateSyntax error

Bad Escaped Character in JSON

Bad escaped character in JSON at position 13

A backslash starts a JSON escape, but the following U is not one of the permitted escape characters.

Broken JSON

{"path": "C:\Users\Ana"}

Highlighted error location: line 1, column 14 · position 13

Parser result

Bad escaped character in JSON at position 13

Why it happens: JSON permits only a small set of escapes, including newline, tab, quote, backslash, and Unicode escapes. Windows paths therefore need doubled backslashes.

Corrected JSON

{"path": "C:\\Users\\Ana"}
IntermediateSyntax error

Bad Control Character: Unescaped Newline in a JSON String

Bad control character in string literal in JSON at position 21

A literal line break is a control character and cannot appear unescaped inside a JSON string.

Broken JSON

{"message": "Line one
Line two"}

Highlighted error location: line 1, column 22 · position 21

Parser result

Bad control character in string literal in JSON at position 21

Why it happens: Control characters inside JSON strings must use escape notation such as \n, \r, or \t.

Corrected JSON

{"message": "Line one\nLine two"}

Numbers and Literals

3 matching examples

IntermediateSyntax error

Unexpected Number: Invalid JSON Number Format

Unexpected number in JSON at position 11

The leading zero completes one number, leaving another digit where the parser expects a comma or closing brace.

Broken JSON

{"price": 01.50}

Highlighted error location: line 1, column 12 · position 11

Parser result

Unexpected number in JSON at position 11

Why it happens: JSON numbers disallow leading zeros, a leading +, trailing decimal points, NaN, and Infinity.

Corrected JSON

{"price": 1.50}
AdvancedSyntax error

Unexpected Token U in JSON

Unexpected token 'u', "{"active": undefined}" is not valid JSON

The word undefined belongs to JavaScript, not JSON, so parsing fails on its first letter.

Broken JSON

{"active": undefined}

Highlighted error location: line 1, column 12 · position 11

Parser result

Unexpected token 'u', "{"active": undefined}" is not valid JSON

Why it happens: JSON supports null but has no undefined literal. JSON.stringify normally omits undefined object properties.

Corrected JSON

{"active": null}
BeginnerSyntax error

Unexpected Token T: JSON Literals Are Lowercase

Unexpected token 'T', "{"active": True}" is not valid JSON

JSON literals are case-sensitive: true, false, and null are the only valid spellings.

Broken JSON

{"active": True}

Highlighted error location: line 1, column 12 · position 11

Parser result

Unexpected token 'T', "{"active": True}" is not valid JSON

Why it happens: True, False, and None are Python literals. Serialize Python values with json.dumps instead of copying a dictionary representation.

Corrected JSON

{"active": true}

API and Response Errors

3 matching examples

AdvancedSyntax error

Unexpected End of JSON Input: Truncated API Response

Unterminated string in JSON at position 21

The parser received only part of a JSON value, often because an API response or stream ended early.

Broken JSON

{"user": {"name": "An

Parser result

Unterminated string in JSON at position 21

Why it happens: The syntax symptom resembles a missing bracket, but intermittent occurrences usually point to transport or server behavior rather than handwritten JSON.

Corrected JSON

{"user": {"name": "Ana"}}
AdvancedSyntax error

Unexpected Token '<' in JSON: HTML Response Instead of JSON

Unexpected token '<', "<html><bod"... is not valid JSON

The response begins with HTML, usually from a 404 page, authentication redirect, or proxy error, rather than the expected JSON body.

Broken JSON

<html><body>Not found</body></html>

Highlighted error location: line 1, column 1 · position 0

Parser result

Unexpected token '<', "<html><bod"... is not valid JSON

Why it happens: JSON cannot begin with <. Inspect response.ok, status, headers, and the raw response body before calling response.json().

Corrected JSON

{"error": "Not found"}
BeginnerSyntax error

Unexpected End of JSON Input: Empty Response Body

Unexpected end of JSON input

JSON.parse requires one complete JSON value, but the response contains no characters at all.

Broken JSON

(empty input)

Parser result

Unexpected end of JSON input

Why it happens: An HTTP 204 response should not be parsed as JSON. For other responses, read the body and decide explicitly how your application treats an empty value.

Defensive JavaScript

const text = await response.text();
const data = text ? JSON.parse(text) : null;

Valid JSON That Still Breaks Applications

2 matching examples

AdvancedParser warning

Duplicate JSON Keys: A Silent Interoperability Problem

No syntax error is required; behavior for duplicate names can differ between implementations.

JSON syntax does not require object member names to be unique, but duplicate names produce implementation-dependent behavior.

Broken JSON

{"id": 1, "name": "Ana", "id": 2}

Parser result

No syntax error is required; behavior for duplicate names can differ between implementations.

Why it happens: For interoperable JSON, object member names should be unique. Duplicate names can be accepted, rejected, or reported differently by consuming software.

Interoperable JSON

{"id": 2, "name": "Ana"}
AdvancedShape error

items.map Is Not a Function After JSON.parse

JSON.parse succeeds; later code may throw TypeError: items.map is not a function

A JSON string is syntactically valid, but application code fails when it assumes the parsed value is an array.

Broken JSON

"Internal Server Error"

Parser result

JSON.parse succeeds; later code may throw TypeError: items.map is not a function

Why it happens: Syntax validation only proves that the text is JSON. It does not prove that the result matches the object, array, or field structure your application expects.

Defensive JavaScript

const parsed = JSON.parse(response);

if (!Array.isArray(parsed)) {
  throw new TypeError('Expected a JSON array');
}

JSON API troubleshooting checklist

Check the response itself before treating every failure as handwritten syntax.

  1. 1Confirm the HTTP response status is successful.
  2. 2Check that Content-Type identifies a JSON response.
  3. 3Read the raw response body while debugging.
  4. 4Do not parse a 204 or a body known to be empty.
  5. 5Validate quotes, commas, brackets, escapes, and numbers.
  6. 6Verify the parsed value has the expected object or array shape.

Offline reference

Download the JSON Errors Cheat Sheet

Keep all 18 parser messages, common causes, and quick fixes nearby as a high-resolution PNG.

Frequently asked questions

Why does my JSON look fine but still fail to parse?

Common invisible causes include smart quotes copied from a word processor, non-breaking spaces, control characters, or a byte-order mark at the start of a file. Inspect the raw text and the parser position rather than relying only on how the content looks.

Is JSON5 or JSONC the same as JSON?

No. JSON5 and JSONC are extensions that may allow comments, trailing commas, or unquoted keys. They are not valid input for strict JSON.parse() or an RFC 8259 JSON parser unless a compatible parser is used.

Why does “Unexpected end of JSON input” happen only sometimes?

Intermittent failures often point to an empty or truncated API response caused by a timeout, proxy, load balancer, or server error. Inspect the status, headers, and raw response body before parsing it.

Technical references and verification

Messages last verified 2026-07-10

Examples were checked with Node.js 24.18.0 and its bundled V8 implementation. Other engines and language libraries can describe the same grammar failure differently.

Published 2026-07-10 · Report a correction or suggest an example.

Debugging a real JSON error?

Paste it into the Validator for its exact location, or open the Formatter to repair common syntax mistakes.