SyntaxError: Unexpected end of input
The parser reached the end of the code (or JSON) while still expecting more — a missing } ) ] or empty JSON.
Seen on:
JavaScript
Meaning
For code: an unclosed brace or bracket. For JSON.parse/response.json(): the body was empty.
Common causes
- Missing closing } or )
- Unterminated template literal
- Empty response passed to JSON.parse
⚡ Quick fix
- Use an editor with bracket matching / run a linter
- Check response.status and length before .json()
Detailed fix by platform
JavaScript
const text = await res.text(); const data = text ? JSON.parse(text) : null;
How to diagnose
- Source — Code or JSON parsing?
- Balance — Are brackets balanced?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026