# SyntaxError: Unexpected end of input

**Code:** `unexpected end of input` · **Category:** JavaScript · **Seen on:** JavaScript

The parser reached the end of the code (or JSON) while still expecting more — a missing } ) ] or empty JSON.

## 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

1. Use an editor with bracket matching / run a linter
2. Check response.status and length before .json()

## Detailed fix by platform

### JavaScript

1. `const text = await res.text(); const data = text ? JSON.parse(text) : null;`

## How to diagnose

1. **Source** — Code or JSON parsing?
2. **Balance** — Are brackets balanced?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/javascript/syntaxerror-unexpected-end-of-input)
