# JSON errors: messages, causes and fixes

> Find what a JSON error message means: exact texts from Chrome, Firefox, Safari, Python, Go, Jackson and PHP, each mapped to its cause and a fix.

- URL: https://jsonstatham.dev/errors/
- Language: English (en)
- Russian version: https://jsonstatham.dev/ru/errors.md
- Updated: 2026-11-08

A parser’s error message tells you where it gave up, rarely why. This reference maps the exact messages of Chrome, Firefox, Safari, Python, Go, Java, C#, PHP and other parsers to the cause behind them, with one page per cause: what the error means, the exact message of each parser, and how to fix it in code.

“Invalid” here means invalid by [RFC 8259](https://www.rfc-editor.org/rfc/rfc8259), the JSON standard. Each cause has a code, the same one the [JSON validator](https://jsonstatham.dev/validator/) reports with its line and column. Found your message below? The page next to it explains it.

## Commas, colons and quotes

| Error message | Code | Page |
| --- | --- | --- |
| `Expected double-quoted property name in JSON` (Chrome), `Illegal trailing comma before end of object` (Python 3.13+) | `trailing_comma` | [Trailing comma](https://jsonstatham.dev/errors/trailing-comma/) |
| `Expected ',' or '}' after property value in JSON` (Chrome), `Expecting ',' delimiter` (Python), `Unexpected string in JSON` (Node.js 18) | `missing_comma` | [Missing comma](https://jsonstatham.dev/errors/missing-comma/) |
| `Expected ':' after property name in JSON` (Chrome), `Expecting ':' delimiter` (Python), `invalid character '1' after object key` (Go) | `missing_colon` | [Missing colon](https://jsonstatham.dev/errors/missing-colon/) |
| `Expecting property name enclosed in double quotes` (Python), `Single quotes (') are not allowed in JSON` (Safari) | `single_quotes` | [Single quotes](https://jsonstatham.dev/errors/single-quotes/) |
| `Unexpected token '“'` (Chrome), `Unrecognized token '“'` (Safari) | `smart_quotes` | [Smart quotes](https://jsonstatham.dev/errors/smart-quotes/) |
| `Expected property name or '}' in JSON` (Chrome), `invalid character 'n' looking for beginning of object key string` (Go) | `unquoted_key` | [Unquoted key](https://jsonstatham.dev/errors/unquoted-key/) |

## Brackets and strings that never close

| Error message | Code | Page |
| --- | --- | --- |
| `Unexpected end of JSON input` (Chrome, Go), `Expected '}'` (Safari), `EOF while parsing an object` (Rust) | `unclosed_object` | [Unclosed bracket: object](https://jsonstatham.dev/errors/unclosed-bracket/#object) |
| `end of data when ',' or ']' was expected` (Firefox), `EOF while parsing a list` (Rust) | `unclosed_array` | [Unclosed bracket: array](https://jsonstatham.dev/errors/unclosed-bracket/#array) |
| `Expected ',' or ']' after array element` for `[1}` (Chrome), `State mismatch (invalid or malformed JSON)` (PHP) | `mismatched_bracket` | [Mismatched bracket](https://jsonstatham.dev/errors/mismatched-bracket/) |
| `Unterminated string in JSON at position` (Chrome), `Unterminated string starting at` (Python) | `unclosed_string` | [Unclosed string](https://jsonstatham.dev/errors/unclosed-string/) |

## Things JSON doesn’t have

| Error message | Code | Page |
| --- | --- | --- |
| `Unexpected token '/'` (Chrome), `Comments are not permitted in JSON.` (Visual Studio Code) | `comment` | [Comments](https://jsonstatham.dev/errors/comments/) |
| `Unexpected token 'N', "[NaN]" is not valid JSON` (Chrome), `Unexpected token 'T'` for `True` (Chrome) | `invalid_literal` | [Invalid literal](https://jsonstatham.dev/errors/invalid-literal/) |
| `Unexpected number in JSON` for `01`, `Unexpected token '.'` for `.5` (Chrome) | `invalid_number` | [Invalid number](https://jsonstatham.dev/errors/invalid-number/) |
| `Bad escaped character in JSON` (Chrome), `Invalid \escape` (Python) | `invalid_escape` | [Invalid escape](https://jsonstatham.dev/errors/invalid-escape/) |
| `Bad control character in string literal in JSON` (Chrome), `Invalid control character at` (Python) | `control_character` | [Control character](https://jsonstatham.dev/errors/control-character/) |

## The start and the end of the document

| Error message | Code | Page |
| --- | --- | --- |
| `Unexpected end of JSON input` on empty input (Chrome), `Expecting value: line 1 column 1 (char 0)` (Python) | `empty_input` | [Empty input](https://jsonstatham.dev/errors/empty-input/) |
| `Unexpected UTF-8 BOM (decode using utf-8-sig)` (Python), `invalid character 'ï' looking for beginning of value` (Go) | `bom` | [Byte order mark](https://jsonstatham.dev/errors/bom/) |
| `Unexpected non-whitespace character after JSON` (Chrome), `Extra data` (Python), `invalid character '{' after top-level value` (Go) | `extra_data` | [Extra data](https://jsonstatham.dev/errors/extra-data/) |
| `Maximum stack depth exceeded` (PHP) | `too_deep` | [Nesting too deep](https://jsonstatham.dev/errors/too-deep/) |
| `Unexpected token '<', "<html>" is not valid JSON` (Chrome), `invalid character '<' looking for beginning of value` (Go) | `unexpected_character` | [Unexpected character](https://jsonstatham.dev/errors/unexpected-character/) |

## Messages with more than one cause

Some messages are not about JSON syntax at all: the server sent HTML, the response was empty, a value was parsed twice. These pages start from the message and lead to the cause.

| Error message | Code | Page |
| --- | --- | --- |
| `Unexpected token '<', "<!DOCTYPE "… is not valid JSON`, `Unexpected token < in JSON at position 0` | usually `unexpected_character` | [Unexpected token '<': HTML instead of JSON](https://jsonstatham.dev/errors/unexpected-token/) |
| `Unexpected end of JSON input`, `unexpected end of JSON input` (Go) | `empty_input` or an unclosed bracket | [Unexpected end of JSON input](https://jsonstatham.dev/errors/unexpected-end-of-json-input/) |
| `"undefined" is not valid JSON`, `"[object Object]" is not valid JSON`, `Unexpected token u in JSON at position 0` | `invalid_literal` | [“undefined” is not valid JSON](https://jsonstatham.dev/errors/undefined-is-not-valid-json/) |
| `Expecting value: line 1 column 1 (char 0)` (Python) | `empty_input`, `unexpected_character` and others | [Expecting value](https://jsonstatham.dev/errors/expecting-value/) |
| `Expecting property name enclosed in double quotes` (Python) | `single_quotes`, `trailing_comma`, `unquoted_key`, `comment` | [Expecting property name](https://jsonstatham.dev/errors/expecting-property-name/) |

## The most common JSON error messages

- [`Unexpected end of JSON input`](https://jsonstatham.dev/errors/unexpected-end-of-json-input/): empty or cut-off input
- [`Unexpected token < in JSON at position 0`](https://jsonstatham.dev/errors/unexpected-token/): an HTML page instead of JSON
- [`Expecting value: line 1 column 1 (char 0)`](https://jsonstatham.dev/errors/expecting-value/): Python got nothing or not JSON
- [`Expecting property name enclosed in double quotes`](https://jsonstatham.dev/errors/expecting-property-name/): Python, usually single quotes
- [`"undefined" is not valid JSON`](https://jsonstatham.dev/errors/undefined-is-not-valid-json/): `JSON.parse(undefined)`
- [`Expected double-quoted property name in JSON at position`](https://jsonstatham.dev/errors/trailing-comma/): usually a trailing comma
- [`Expected property name or '}' in JSON at position 1`](https://jsonstatham.dev/errors/unquoted-key/): an unquoted key or a single quote
- [`Expected ',' or '}' after property value in JSON`](https://jsonstatham.dev/errors/missing-comma/): a missing comma
- [`Unterminated string in JSON at position`](https://jsonstatham.dev/errors/unclosed-string/): a string that never closes
- [`Bad control character in string literal in JSON`](https://jsonstatham.dev/errors/control-character/): a raw line break or tab in a string
- [`Unexpected non-whitespace character after JSON`](https://jsonstatham.dev/errors/extra-data/): two documents in one
- [`Extra data: line 1 column`](https://jsonstatham.dev/errors/extra-data/): the same in Python, often JSON Lines
- [`Unexpected token u in JSON at position 0`](https://jsonstatham.dev/errors/undefined-is-not-valid-json/): `undefined` in older Chrome and Node.js
- [`JSON.parse: unexpected character at line 1 column 1 of the JSON data`](https://jsonstatham.dev/errors/unexpected-token/): Firefox, often HTML

## How to read a JSON error message

1. **Find the position.** Chrome gives `position N` counted from 0, plus `line L column C` counted from 1; Python gives `line L column C (char N)`; Go gives a byte offset in `SyntaxError.Offset`; System.Text.Json gives `LineNumber` and `BytePositionInLine`, both from 0. The [position finder](https://jsonstatham.dev/json-position/) turns any of them into a place in the text.
2. **Look just before it.** The position is where the parser gave up. A missing comma is reported at the next value, a trailing comma at the bracket after it, an unclosed bracket at the very end of the input.
3. **Fix one error at a time.** The first error can produce the next ones; after a fix, parse again.
4. **Check what you parsed.** If the error is at line 1 column 1, the text probably isn’t JSON at all: an empty response, an HTML page, the string `undefined`.

## JSON errors FAQ

### Why do Chrome and Python give different messages for the same JSON?

Each parser describes what it expected at the point where it stopped, in its own words. The cause is the same; the tables on each page here list the exact message of every major parser side by side.

### Why does the error position point after the real mistake?

A parser only knows something is wrong when it reads a character that can’t follow. For a trailing comma that is the bracket after it; for a missing comma, the next value; for an unclosed bracket, the end of the input.

### What is the difference between position, char and column?

Chrome’s position and Python’s char count characters from 0. Columns count from 1 within a line. Go, serde and System.Text.Json count bytes, so any character outside basic Latin before the error shifts their numbers.
