Fix "Unexpected non-whitespace character after JSON"
JavaScript / Python · JSON error
Opens the editor with a broken example loaded and repaired, entirely in your browser — nothing is uploaded.
What causes it
A JSON document must contain exactly one top-level value. This error (Python calls it Extra data) means the parser successfully read a complete value and then hit more content that should not be there. Common causes:
- Concatenated objects —
{"a":1}{"b":2}with nothing joining them. Wrap them in an array and add a comma. - Newline-delimited JSON (NDJSON) — one object per line. That is a valid stream format, but you must parse it line by line, not all at once.
- A stray character after the closing bracket — a duplicated brace, a trailing log line, or copy-paste leftovers.
How to fix it
- Look at the position/column — the extra content starts right after the first complete value.
- If you have multiple objects, wrap them in [ ] and separate them with commas.
- If it is NDJSON, split on newlines and JSON.parse() each line separately.
- Paste it into JSON Wallet to see exactly where the first value ends and the extra data begins.
Before and after
Broken:
{"a": 1}
{"b": 2}Fixed:
[
{"a": 1},
{"b": 2}
]Want to fix your own JSON instead of the example? Open the editor, paste it in, and click Repair — it runs entirely in your browser.
Frequently asked questions
What is NDJSON and why does it cause this?
Newline-delimited JSON puts one JSON object per line. It is a streaming format, so a single JSON.parse() call over the whole thing fails after the first line. Parse each line individually.
How do I combine multiple objects into one document?
Wrap them in an array and separate them with commas: [{"a":1}, {"b":2}]. Then it is a single valid JSON value.
Related JSON errors
Fix "Unexpected token in JSON at position N"
The most common JSON.parse() error. It means the parser hit a character it did not expect — usually HTML, an already-parsed object, or a stray token.
Fix "Unexpected end of JSON input"
The parser reached the end of the text while still expecting more — an empty response, a truncated payload, or an unclosed bracket or quote.
For a full reference of JSON mistakes, read Common JSON errors and how to fix them.