"Unexpected end of JSON input" in JavaScript — What It Means and How to Fix It

What the JavaScript error "Unexpected end of JSON input" means and how to fix it.

Published October 30, 2026

"Unexpected end of JSON input" is occurs when JSON.parse() is given an incomplete or empty JSON string.

Key points

  • Check the browser console's stack trace to find exactly which line and call triggered the error

Example

JSON.parse('')  // SyntaxError: Unexpected end of JSON input
More JavaScript articles