Need help with your JSON?

Try our JSON Formatter tool to automatically identify and fix syntax errors in your JSON. JSON Formatter tool

JSON Parser Error Messages Explained

Most JSON parser errors boil down to a short list of problems: broken punctuation, broken strings, broken numbers, extra content after a valid JSON value, or content that was never JSON in the first place. The hard part is that different runtimes phrase those failures differently.

This guide translates the message you see into the fastest likely fix, with examples from JavaScript and Python and a few current parser notes from MDN's JSON.parse error reference, the Python json docs, and RFC 8259.

Quick Lookup

If you landed here with a specific error message, start with the category below and then jump to the matching section.

MessageUsually meansCheck first
Unexpected token '<' in JSON at position 0You usually received HTML or plain text instead of JSON.Inspect the raw response body, HTTP status, and Content-Type header.
Expected property name / property name enclosed in double quotesObject keys are malformed, or a trailing comma/comment confused the parser.Use double quotes for keys and remove comments or trailing commas.
Unexpected non-whitespace character after JSON / Extra dataThe parser finished one valid JSON value and then found more content.Look for concatenated objects, JSONL/NDJSON input, or stray text after the closing } or ].
Unterminated string / bad control character / Invalid control characterA string is missing a closing quote or contains an unescaped newline, tab, quote, or backslash.Check the nearest string literal and escape special characters.
Unexpected end of JSON input / unexpected end of dataThe payload is truncated, incomplete, or empty.Verify the full payload arrived and that you are not parsing an empty response.
Unexpected number / missing digits after decimal pointA number format is invalid for JSON.Remove leading zeros and reject NaN, Infinity, and unfinished decimals like 1.

How to Read the Location Info

The reported location is your best clue. In JavaScript you often get a character position. In Python,JSONDecodeError exposes the message plus pos,lineno, and colno. The parser usually detects the problem when it reaches the next impossible character, so the real mistake is often one character before the reported position.

Fast debugging rule

Look at the reported character, then inspect 10 to 20 characters before it. Most JSON bugs are either missing punctuation, a broken string escape, or extra text after a valid closing brace or bracket.

Common JSON Error Families

Exact wording changes across engines. The category is what matters: once you know whether the failure is about object syntax, separators, strings, extra data, incomplete input, or numbers, the fix gets much faster.

1. Property names, quotes, and object syntax

This family usually means the parser reached an object member where strict JSON syntax was broken.

Message variants you may see

  • Expected property name or '}'
  • Expected double-quoted property name in JSON
  • Expecting property name enclosed in double quotes

Likely causes

  • Single quotes around keys or string values
  • Unquoted keys such as name: "Alice"
  • Trailing commas inside objects
  • Comments copied from JavaScript, JSONC, or JSON5

How to fix it

  • Wrap every key and every string value in double quotes.
  • Remove comments and trailing commas.
  • If the source is a config format that allows comments, convert it to strict JSON before parsing.

Problematic JSON

{
  'name': "Alice",
  age: 30,
}

Valid JSON

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

The exact wording varies by parser. Firefox often reports a more specific property-name error, while V8-based runtimes may report a broader unexpected-token style message for the same root cause.

2. Missing commas, trailing commas, and array separators

JSON separators are minimal and strict: commas go between elements or members, never after the last one.

Message variants you may see

  • Expected ',' or ']' after array element
  • Expected ',' or '}' after property value in object
  • Unexpected token ] / } in JSON

Likely causes

  • Missing a comma between array elements
  • Missing a comma between object members
  • Trailing commas copied from JavaScript object literals

How to fix it

  • Insert commas only between items, not after the last item.
  • Check one character before the reported location. The parser often notices the problem only when it reaches the next token.

Problematic JSON

[
  1
  2,
  3,
]

Valid JSON

[
  1,
  2,
  3
]

RFC 8259 defines comma as a value separator, but JSON has no grammar rule for a trailing comma.

3. Strings, escapes, and control characters

A JSON string started correctly but contains characters that must be escaped, or it never closed.

Message variants you may see

  • Unterminated string
  • bad control character in string literal
  • Invalid control character
  • bad escape character
  • bad Unicode escape

Likely causes

  • A missing closing double quote
  • A raw newline or tab inside a string
  • An unescaped quote or backslash
  • A malformed Unicode escape such as \u12G4

How to fix it

  • Escape quotes as \" and backslashes as \\.
  • Replace raw newlines with \n and tabs with \t.
  • Validate every \u escape uses exactly four hexadecimal digits.

Problematic JSON

{
  "message": "Line 1
Line 2"
}

Valid JSON

{
  "message": "Line 1\nLine 2"
}

Many parsers report the position where they finally give up, not necessarily the first character that was wrong.

4. Extra data after a complete JSON value

A valid JSON text is one serialized value with optional surrounding whitespace. After that, the parser expects nothing else.

Message variants you may see

  • Unexpected non-whitespace character after JSON
  • Extra data

Likely causes

  • Two objects or arrays concatenated together
  • Debug text or a stack trace appended after valid JSON
  • Trying to parse JSON Lines or NDJSON as one normal JSON document

How to fix it

  • Wrap multiple values in an array if you need one JSON document.
  • If the source is NDJSON or JSONL, parse it line by line with the right tool.
  • Trim any accidental banner text or logging output after the closing brace or bracket.

Problematic JSON

{"a": 1}{"b": 2}

Valid JSON

[
  { "a": 1 },
  { "b": 2 }
]

RFC 8259 defines a JSON text as ws value ws, so extra non-whitespace content after the first value is invalid.

5. Unexpected end of input or truncated payloads

The parser reached the end of the string before the JSON structure was complete.

Message variants you may see

  • Unexpected end of JSON input
  • unexpected end of data
  • Unterminated string starting at

Likely causes

  • A missing closing brace, bracket, or quote
  • A network response that was cut off or partially written
  • Trying to parse an empty response body
  • Calling response.json() on a 204 No Content response

How to fix it

  • Confirm the source payload is complete before parsing.
  • If this came from HTTP, check for 204 responses, proxy errors, or truncated downloads.
  • If the body may be empty, guard for that before calling the parser.

Problematic JSON

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

Valid JSON

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

An empty string is not valid JSON. If you expect "no data", represent it as null, [] or {} depending on your contract.

6. Invalid numbers and non-standard literals

JSON numbers are stricter than JavaScript literals and many hand-written formats.

Message variants you may see

  • Unexpected number in JSON
  • missing digits after decimal point
  • no number after minus sign
  • unexpected keyword

Likely causes

  • Leading zeros such as 01
  • Unfinished decimals such as 1.
  • Broken exponents such as 1e or 1e+
  • Using NaN, Infinity, or -Infinity in strict JSON

How to fix it

  • Use plain decimal numbers like 0, 1, or 1.0.
  • Replace NaN and Infinity with a real value, null, or a string based on your schema.
  • Generate numbers with a serializer instead of string concatenation.

Problematic JSON

{
  "count": 01,
  "ratio": 1.,
  "value": NaN
}

Valid JSON

{
  "count": 1,
  "ratio": 1.0,
  "value": null
}

RFC 8259 does not permit NaN or Infinity. Python's standard library can accept those values by default, so cross-language behavior may differ unless you tighten the decoder.

When the Payload Is Not Actually JSON

Many real-world parse failures are upstream response problems, not syntax mistakes inside a valid JSON document.

  • If the first character is <, you probably got an HTML error page, login page, or CDN/proxy response instead of JSON.
  • If the body is empty, the parse failure may be correct: an empty string is not JSON.
  • MDN notes that Response.json() throws SyntaxError when the body cannot be parsed as JSON, but it can also throw TypeError when body decoding fails, for example because Content-Encoding is wrong.
  • If the payload came from a human-edited config file, confirm whether it is strict JSON or a looser format such as JSONC or JSON5.

Useful fetch debugging pattern

const response = await fetch(url);
const text = await response.text();

console.log(response.status, response.headers.get("content-type"));
console.log(text.slice(0, 200));

const data = JSON.parse(text);

This is often the fastest way to confirm whether the server returned JSON, HTML, an empty body, or a truncated payload.

Compatibility Notes That Matter

  • Message text is not standardized. The same invalid input can produce different wording in Firefox, Chrome, Node.js, Python, and backend libraries.
  • JSON itself is standardized. RFC 8259 allows one JSON value at the top level, not just objects or arrays.
  • Python's standard library documents some intentionally non-strict behavior, such as acceptingNaN and Infinity unless you override the decoder. That can hide invalid JSON that a stricter parser will reject later.
  • A byte order mark at the start of a payload can also create interoperability problems. RFC 8259 says it must not be added to transmitted JSON, and parser behavior varies when it appears anyway.

Preventing Parse Errors

The fastest fix is usually upstream: generate valid JSON automatically and verify the raw payload before it reaches your parser.

  • Serialize native data structures with JSON.stringify, json.dumps, or equivalent instead of hand-building strings.
  • Log the raw payload in development before parsing, but redact secrets and tokens.
  • Validate Content-Type and HTTP status before assuming a response body is JSON.
  • Use a JSON-aware formatter or validator to pinpoint the first syntax break quickly.
  • Use the right parser for the format you actually have: JSON, NDJSON/JSONL, JSON5, or JSONC are not interchangeable.

If you treat the error message as a category plus a location hint, most JSON failures become routine to fix. Start with the character position, inspect the raw payload, and verify that the content is strict JSON rather than a nearby format or an upstream error page.

Need help with your JSON?

Try our JSON Formatter tool to automatically identify and fix syntax errors in your JSON. JSON Formatter tool