Unexpected end of JSON input: an empty or cut-off body
By Santhi · Messages captured October 9, 2026 on 11 runtimes · How we test
The parser ran out of text before the JSON was complete. Either there was no text at all (an empty response body), or the text stops part-way through, like a download cut off in the middle.
What each runtime prints
We ran these inputs through JSON.parse in each browser and Node version, and through json.loads in Python. These are the messages exactly as printed.
(empty string)| Runtime | Exact message |
|---|---|
| Chrome 151Node 24Node 22Node 20Node 18 | Unexpected end of JSON input |
| Firefox 153 | JSON.parse: unexpected end of data at line 1 column 1 of the JSON data |
| Safari 26 (WebKit)Bun | JSON Parse error: Unexpected EOF |
| Python 3.13Python 3.12Python 3.10 | JSONDecodeError: Expecting value: line 1 column 1 (char 0) |
{"items": [1, 2| Runtime | Exact message |
|---|---|
| Chrome 151Node 24Node 22 | Expected ',' or ']' after array element in JSON at position 15 (line 1 column 16) |
| Firefox 153 | JSON.parse: end of data when ',' or ']' was expected at line 1 column 16 of the JSON data |
| Safari 26 (WebKit)Bun | JSON Parse error: Expected ']' |
| Node 20 | Expected ',' or ']' after array element in JSON at position 15 |
| Node 18 | Unexpected end of JSON input |
| Python 3.13Python 3.12Python 3.10 | JSONDecodeError: Expecting ',' delimiter: line 1 column 16 (char 15) |
- Only an empty body gives "Unexpected end of JSON input" in Chrome and Node 20+. Cut-off JSON gets a more specific message there, such as "Expected ',' or ']' after array element", which points at the column where the text stops.
- Node 18 says "Unexpected end of JSON input" for both, so on Node 18 you cannot tell an empty body from a cut-off one.
- Python reports an empty body as "Expecting value: line 1 column 1 (char 0)", the same message it gives for an HTML page.
Edit it or paste your own. It runs in your browser; nothing is uploaded.
Common causes
- 1
A 204 No Content or a HEAD request
Many APIs answer DELETE and some PUT requests with 204 and no body. Calling res.json() on it throws.
- 2
An error with no body
A 401, 403 or 500 from some servers and gateways has no body at all. The code calls res.json() before checking res.ok.
- 3
A response cut off by a timeout or a size limit
A proxy timeout, a dropped connection, or a body size limit ends the response early. The JSON stops mid-value.
- 4
A stream read too early
Parsing the first chunk of a streamed response, or a file that another process is still writing.
- 5
A database column or log line that was too short
JSON saved into a VARCHAR(255) column, or a log system that cuts long lines, keeps only the start of the document.
How to fix it
Read the body as text first. An empty string is a normal answer for some requests; handle it before parsing.
JavaScript
const res = await fetch(url, { method: 'DELETE' });
if (!res.ok) throw new Error(`${res.status} from ${res.url}`);
const text = await res.text();
const data = text ? JSON.parse(text) : null; // 204 and empty bodies give nullPython
r = requests.delete(url, timeout=10)
r.raise_for_status()
data = r.json() if r.content else None # 204 and empty bodies give None- If the text is not empty but stops early, compare its length with the Content-Length header. A shorter body means the connection or a proxy cut it off.
- The JSON Repair tool can close cut-off JSON so you can read what arrived, but the last value may be incomplete. Fix the source rather than shipping repaired data.