Extra data: line 1 column N (char N)
json.decoder.JSONDecodeError: Extra data: line 1 column 25 (char 24)
Where JSON.parse stops
{"id": 1, "name": "Ada"}
{"id": 2, "name": "Grace"}What it means
json.loads reads exactly one JSON value and then stops. This message means it read one just fine and found more text sitting after it. Your file is not broken. It is two documents where the parser expected one, and the offset tells you where the second one starts.
Last verified on Python 3.9, 3.11, 3.12, 3.13 and 3.14.
It opens with the error marked. Nothing is uploaded. Find where the error is.
- Usually
- It is JSON Lines, not JSONA file that was appended toTwo responses concatenated
- Fix
- Work out which format you have.
The fix
Work out which format you have. If it is JSON Lines, parse one line at a time with [json.loads(line) for line in f if line.strip()]. If it really should be one document, wrap the values in [ ] and put commas between them, the way the fixed example does.
{"id": 1, "name": "Ada"}
{"id": 2, "name": "Grace"}Lines 1, 2, 3 and 4 change.
[
{"id": 1, "name": "Ada"},
{"id": 2, "name": "Grace"}
]How the message appears
Here the char offset is where the second document starts, which is the most useful number on this page.
- json.decoder.JSONDecodeError: Extra data: line 1 column 25 (char 24)
- json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 25)
What causes it
It is JSON Lines, not JSON
One complete JSON object per line, no commas, no wrapping array.
.jsonland.ndjsonfiles are built this way on purpose, and so is the output of most log pipelines and a lot of streaming APIs. Nothing is wrong with the file. It just needs a different reader.A file that was appended to
A script that opens the file with mode
aand callsjson.dumpon every run stacks one document on top of another. Each one is valid on its own. The file as a whole is not a single value.Two responses concatenated
A proxy or a retry wrote both bodies into the same buffer. The offset lands exactly on the second
{, and that is how you tell this apart from a syntax error inside one document.
Worth knowing
Watch outCheck what reads the file before you convert a .jsonl into an array. JSON Lines exists so a huge file can be streamed one record at a time instead of held in memory all at once. Wrapping it in an array throws that away.
Notejson.JSONDecoder().raw_decode(text) parses one value and hands back the index it stopped at. That is the supported way to walk a stream of documents stacked end to end.