JSON & Schema
Unexpected End of JSON Input: Causes and How to Fix It
Unexpected end of JSON input means the parser reached the end while it still expected a value, closing quote, bracket, or brace.
Published
What “Unexpected end of JSON input” means
The message identifies an incomplete parse, not the business cause. The missing bytes may originate in the source, transport, stream handling, or string construction.
Empty input and empty HTTP responses
An empty successful response is still not a JSON document. Check status, content type and body length before parsing.
JSON.parse("")Missing } or ]
A nested structure may need more than one closing token; format the surrounding region rather than appending braces blindly.
{"items":[1,2,3]Unterminated strings
A missing quote can make later braces look like string content.
{"name":"Ada}Truncated API, network and stream payloads
- Confirm the complete response was read.
- Check content-length and decompression errors.
- Await stream completion before parsing.
- Log safe byte counts and status—not sensitive raw payloads.
How to diagnose safely
Reproduce with a synthetic payload, preserve the original evidence, validate locally, and fix the producer or read boundary. If data is genuinely missing, a local formatter cannot reconstruct it reliably.
Try the example
Reproduce an incomplete nested object
The payload ends before the string and object structure are closed.
{"user":{"id":1,"name":"Ada"Expected result: The tool reports invalid JSON without changing or guessing the missing structure.
Try the example
Validate the complete object
Compare the same data after both object levels are closed.
{"user":{"id":1,"name":"Ada"}}Expected result: The JSON validates and can be minified safely.
Validate the payload
Inspect the failing JSON
Run the exact text locally to confirm its parse boundary before changing the producer.