unexpected end of input JavaScript Origin: On your device Last updated 14 Oct 2026

SyntaxError: Unexpected end of input

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

Exact message you may see Unexpected end of inputUnexpected end of JSON input
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

  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?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

already declared — SyntaxError: Identifier 'x' has already been declared (JavaScript)already declaredawait outside async — SyntaxError: await is only valid in async functions and the top level bodies of modules (JavaScript)await outside asynccircular JSON — TypeError: Converting circular structure to JSON (JavaScript)circular JSONentity.parse.failed — API Error: Malformed JSON in request body (entity.parse.failed / JSON parse error) (API)entity.parse.failedGraphQL Syntax Error — GraphQL: Syntax Error: Expected Name, found <EOF> / Unexpected } (API)GraphQL Syntax Errorinvalid regex — SyntaxError: Invalid regular expression: /x/: Unterminated group (JavaScript)invalid regexinvalid token — SyntaxError: Invalid or unexpected token (JavaScript)invalid tokenInvalidDefinitionException — com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class X and no properties discovered (Java)InvalidDefinitionExce…unexpecte…

Explore the map of this error Full error map →

🧠 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.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.