A JSON parse error stops your application cold. Whether it's SyntaxError: Unexpected token in JavaScript or json.JSONDecodeError in Python, the fix is usually simple once you know what to look for. This guide covers every common parse error with the exact cause and solution.

The golden rule: paste it into a validator first

Before reading any further — paste your broken JSON into a validator. It will tell you the exact line and character causing the error, saving you minutes of manual searching.

Try it free — JSON Formatter & Validator

Paste your JSON and see the exact error highlighted. Free, instant, no upload required.

Open tool →

JavaScript JSON parse errors

"SyntaxError: Unexpected token } in JSON"

Cause: Trailing comma before a closing bracket.

// Broken
const data = JSON.parse('{"name":"Alice","age":28,}');

// Fixed — remove trailing comma
const data = JSON.parse('{"name":"Alice","age":28}');

"SyntaxError: Unexpected token ' in JSON"

Cause: Single quotes used instead of double quotes.

// Broken
JSON.parse("{'name':'Alice'}");

// Fixed
JSON.parse('{"name":"Alice"}');

"SyntaxError: Unexpected token u in JSON at position 0"

Cause: The value being parsed is undefined, not a JSON string.

// Broken — fetch response not awaited
const data = JSON.parse(response); // response is undefined

// Fixed
const response = await fetch(url);
const data = await response.json(); // use .json() not JSON.parse()

"SyntaxError: Unexpected end of JSON input"

Cause: The JSON string is incomplete — truncated response or missing closing bracket.

// Broken — missing closing brace
JSON.parse('{"name":"Alice"');

// Fixed
JSON.parse('{"name":"Alice"}');

"SyntaxError: Unexpected token < in JSON at position 0"

Cause: An HTML error page was returned instead of JSON. Your API returned a 404 or 500 HTML page.

// Always check status before parsing
const response = await fetch(url);
if (!response.ok) {
  throw new Error('API error: ' + response.status);
}
const data = await response.json();

Python JSON parse errors

"json.JSONDecodeError: Expecting value"

Cause: Empty string, None, or HTML being passed to json.loads().

import json, requests

response = requests.get(url)
# Always check status code first
response.raise_for_status()
data = response.json()  # use .json() method, not json.loads(response)

"json.JSONDecodeError: Extra data"

Cause: Multiple JSON objects in the string instead of one.

import json

# Broken — two objects concatenated
text = '{"a":1}{"b":2}'

# Fixed — parse line by line (NDJSON/JSONL format)
for line in text.strip().split("
"):
    obj = json.loads(line)

Quick fix checklist

  • Remove all trailing commas (after last item in objects and arrays)
  • Replace all single quotes with double quotes
  • Remove any JavaScript comments (// comment or /* */)
  • Make sure all keys are quoted strings
  • Check for unescaped quotes inside strings: "say \"hello\""
  • Verify the API actually returned JSON (check Content-Type header)