Home / JSON Error Fixes / JSONDecodeError: Expecting value

JSONDecodeError: Expecting value

This Python error usually means you are parsing an empty string or non-JSON content. Use this checklist to isolate the real source quickly.

Typical Causes

  • Empty response body or file read returned an empty string.
  • HTML or text response instead of JSON.
  • BOM or invisible control characters at the start.
  • JSON string was double-encoded and not decoded first.

Debug Checklist

  1. Print the raw string length and first 200 characters.
  2. Validate using JSON Validator.
  3. If it is escaped, decode with String to JSON.
  4. Format with JSON Formatter.

Python Example

import json
raw = response.text
print(len(raw), raw[:200])

data = json.loads(raw)

Recovery Strategy

Once the payload is valid JSON, compare against a known-good response using JSON Compareto find drift in shape or types.

FAQ

Why does this only happen on some records?

Some rows may be empty or contain stringified JSON. Check for null or empty inputs before parsing.

Should I ignore the error and return null?

Only if the upstream system guarantees optional data. Otherwise, fix the source payload.

About the Author

Formatterjson.org Editorial Team

We build and maintain formatterjson.org, a privacy-first suite of JSON, XML, YAML, and conversion tools used by developers and data teams. Our guides are based on real debugging workflows and tool usage patterns.

Last updated: March 16, 2026

Explore More SEO Hubs