formatjson.pro
Validate, pretty-print or minify JSON in your browser — nothing is uploaded.

JSONDecodeError: Extra data

json.loads() parsed one complete JSON value and then found more content after it. This almost always means you have JSON Lines / NDJSON (one object per line) or several objects concatenated. Parse them one at a time instead of as a single document.

What the error means

A JSON document holds exactly one top-level value. The decoder read a valid value, then hit extra characters where it expected the end of input. The "char N" position marks where the second value begins.

The common causes

1. JSON Lines / NDJSON. Log files and streaming APIs emit one JSON object per line. Read the file line by line: [json.loads(line) for line in f if line.strip()].
2. Concatenated objects. Two responses glued together ({...}{...}). Split them, or use json.JSONDecoder().raw_decode() in a loop to consume one value at a time.
3. Trailing junk. A stray character, a duplicated body, or a shell that appended output. Trim after the first complete value.

Fix it fast

If it is NDJSON, split on newlines and parse each line. The tool above will not merge multiple documents — this error is structural, not a syntax typo — but you can paste a single line to confirm each object is valid on its own.

FAQ

How do I parse JSON Lines in Python?

Iterate the file and parse each non-empty line: results = [json.loads(l) for l in f if l.strip()]. Do not call json.loads on the whole file.

What is raw_decode?

json.JSONDecoder().raw_decode(s, idx) decodes one value and returns where it stopped, so you can loop through concatenated JSON values.

Why line 1 column that's way past my object?

The position points to the first character after the first complete value — i.e. where the extra data starts.