Formatter Validator Minifier Escape / Unescape JSON ↔ String JSON ↔ YAML JSON → CSV NDJSON / JSON Lines JSON → Types JSON ↔ XML JSON Diff JSON Patch Canonicalize (RFC 8785) Schema Validator Schema Generator JSONPath Tester JWT Decoder JSON Errors Schemas More Tools
JSONTools / JSON errors / NDJSON fed to a whole-document JSON parser
JSON error registry · Wrong input entirely

NDJSON fed to a whole-document JSON parser

Newline-delimited JSON: one complete document per line. Each line is valid on its own, but the file as a whole is not a single JSON text. Log pipelines, BigQuery exports and streaming APIs all use this format.

The input

Fails to parse
{"a":1}
{"a":2}
Parses correctly
[{"a":1}, {"a":2}]

Open this broken input in the formatter →

How to fix it

Read line by line and parse each line separately.

Also called JSON Lines or JSONL. Extensions `.ndjson` and `.jsonl` signal it, but plenty of tools still write it to a `.json` file.

What each parser reports

Every message below was captured by running this exact input through the parser named. 20 of 21 parsers rejected it; 1 accepted it.

Parser Exact message
CPython json.loads
CPython 3.12.3
Extra data: line 2 column 1 (char 8)
what this message means →
encoding/json Unmarshal
Go go1.22.2
invalid character '{' after top-level value
what this message means →
Gson
Java 21.0.12
Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2 path $
what this message means →
Gson JsonParser (lenient off)
Java 21.0.12
Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2 path $
what this message means →
hjson
Node.js 22.22.2
Syntax error, found trailing characters at line 2,1 >>>{"a":2} {"a":3} ...
what this message means →
Jackson ObjectMapper
Java 21.0.12
accepted — no error
JavaScriptCore JSON.parse
JavaScriptCore (Bun 1.4.1)
JSON Parse error: Unable to parse JSON string
what this message means →
json-bigint
Node.js 22.22.2
Syntax error
JSON5
Node.js 22.22.2
JSON5: invalid character '{' at 2:1
what this message means →
JSON::PP
Perl 5.038002
garbage after JSON object, at character offset 9 (before ""a":2}\x{a}{"a":3}")
what this message means →
json_decode
PHP 8.3.6
Syntax error
Newtonsoft.Json JsonConvert
Newtonsoft.Json 13.0.3 on .NET 8.0.30
Additional text encountered after finished reading JSON content: {. Path '', line 2, position 0.
what this message means →
Newtonsoft.Json JsonTextReader
Newtonsoft.Json 13.0.3 on .NET 8.0.30
Additional text encountered after finished reading JSON content: {. Path '', line 2, position 0.
what this message means →
orjson
CPython 3.12.3
unexpected content after document: line 2 column 1 (char 8)
what this message means →
Ruby JSON.parse
Ruby 3.2.3
unexpected token at '{"a":2} {"a":3}'
serde_json::from_str
Rust (serde_json 1.x)
trailing characters at line 2 column 1
what this message means →
SpiderMonkey JSON.parse
SpiderMonkey 115
JSON.parse: unexpected non-whitespace character after JSON data at line 2 column 1 of the JSON data
what this message means →
System.Text.Json Deserialize
.NET 8.0.30
'{' is invalid after a single JSON value. Expected end of data. Path: $ | LineNumber: 1 | BytePositionInLine: 0.
what this message means →
System.Text.Json JsonDocument
.NET 8.0.30
'{' is invalid after a single JSON value. Expected end of data. LineNumber: 1 | BytePositionInLine: 0.
what this message means →
ujson
CPython 3.12.3
Trailing data
V8 JSON.parse
Node.js 22.22.2
Unexpected non-whitespace character after JSON at position 8 (line 2 column 1)
what this message means →

What the specification says

The exact sections that govern this error. Descriptions are our paraphrase; follow the links for the normative text.

Body Section
IETF
A JSON text is a single value with optional surrounding whitespace (JSON-text = ws value ws). The token set is six structural characters, strings, numbers and three literal names — nothing else.
Ecma International
Lists the six structural tokens, the three literal name tokens, and the four whitespace code points. Whitespace is not allowed within a token.

Other errors in this category

Empty string passed to a JSON parser

The document is zero bytes. Almost always an upstream failure: an HTTP call that returned 204, a file that was never written, a va…

Whitespace-only input

The document contains only spaces, tabs or newlines. Same family as empty input — a file was created but never filled.…

Extra data after a JSON document

Two complete documents concatenated. Usually a file appended to rather than overwritten, or several API responses written to the s…

Trailing characters after a JSON document

Non-whitespace content after the closing brace — a stray word, a shell prompt captured with the output, or a log line appended to …

HTML received where JSON was expected

The response body is an HTML page, not JSON. The server returned an error page, a login redirect, a proxy or captive-portal inters…

The literal string 'undefined' as a JSON document

A JavaScript variable holding `undefined` was interpolated into a string and sent as the body. `String(undefined)` is `"undefined"…

Bare unquoted word as a JSON document

A single token with no quotes. Either a plain-text response being parsed as JSON, or a string value that was never quoted.…

Whole JSON document wrapped in quotes

The document is double-encoded — a JSON string containing JSON, or a shell variable that kept its surrounding quotes.…

← All JSON parser errors