JSONDecodeError 🐍 Python

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The text passed to json.loads() isn’t JSON — at char 0 it’s usually empty or HTML.

Seen on: Python

Meaning

“Expecting value … (char 0)” means the very first character isn’t valid JSON: an empty response, an HTML error page, or a BOM. requests’ response.json() raises the same error.

Common causes

  • Empty response body (204, error)
  • HTML error/login page instead of JSON
  • File with BOM (use utf-8-sig)
  • Single quotes / Python dict repr instead of JSON

⚡ Quick fix

  1. Print response.status_code and response.text[:200] before parsing
  2. Check Content-Type
  3. Use json.loads(s) only on real JSON; ast.literal_eval for Python reprs

Detailed fix by platform

Python

  1. python
    r = requests.get(url, timeout=10)
    r.raise_for_status()
    data = r.json()

How to diagnose

  1. Raw — What is the text?
  2. Status — HTTP status code?

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