Common causes
1. A JSON Lines (NDJSON) file parsed as one document
Logs, exports and streaming APIs often write one JSON object per line. Parse each line separately, or open the text in the JSON Lines formatter. If you need a single document, wrap the records in an array.
{"event": "login", "user": "ada"}
{"event": "logout", "user": "ada"}[
{"event": "login", "user": "ada"},
{"event": "logout", "user": "ada"}
]2. One closing bracket too many
An extra } or ] closes the root early, and everything after it counts as trailing content. Remove the surplus bracket; PasteKit names it as “no open bracket to close”.
{"user": {"name": "ada", "roles": ["admin"]}}}{"user": {"name": "ada", "roles": ["admin"]}}3. Server output appended after the JSON
A PHP warning, a debug print, or framework output written after the response body ends up behind the JSON. Make sure the handler writes nothing but the serialized body, and stops after it.
{"ok": true}
<br />
<b>Warning</b>: Undefined variable $user in /var/www/api.php on line 42{"ok": true}4. Two responses concatenated
Reading a socket or file in a loop and appending every chunk to the same buffer can join two complete documents, such as }{. Split them at message boundaries, or use a format with explicit framing such as JSON Lines.
{"id": 1, "status": "queued"}{"id": 1, "status": "done"}[{"id": 1, "status": "queued"}, {"id": 1, "status": "done"}]Frequently asked questions
How do I parse a JSON Lines file in JavaScript?
Split on newlines and parse each non-empty line: text.split(‘\n’).filter(Boolean).map((line) => JSON.parse(line)). In Python, iterate over the file and call json.loads on each line.
Is whitespace after the JSON allowed?
Yes. Spaces, tabs, newlines and carriage returns before or after the value are ignored. Anything else, including a semicolon or a second value, is an error.
Why does Python call it "Extra data"?
Python’s json.loads reports the same condition as “Extra data” with the line and column where the extra text begins. Its raw_decode method can parse the first value and tell you where it ended.