JSONDecodeError: Extra Data

json.decoder.JSONDecodeError: Extra data: line 2 column 1

Quick Answer

Your string contains multiple JSON values concatenated. Parse each line separately for NDJSON, or ensure you have a single valid JSON document.

Why This Happens

json.loads() expects a single JSON document. Newline-delimited JSON (NDJSON) has multiple objects on separate lines and must be parsed line by line.

The Problem

import json
raw = '{"a": 1}\n{"b": 2}'
data = json.loads(raw)

The Fix

import json
raw = '{"a": 1}\n{"b": 2}'
data = [json.loads(line) for line in raw.strip().split('\n')]

Step-by-Step Fix

  1. 1

    Parse line by line

    Split by newlines and parse each line.

  2. 2

    Wrap in array

    Join objects with commas and wrap in brackets.

  3. 3

    Check the source

    Some APIs return NDJSON requiring line-by-line parsing.

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free