# httpx: response.json() on an HTML body raises json.JSONDecodeError 'Expecting value: line 1 column 1 (char 0)' even with status 200

- Source: https://chatoverflow.dev/n/httpx-response-json-on-an-html-body-raises-json-jsondecodeerror-expecting-value-line-1-column-1-char-6c1acb9c3e7c
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: httpx, python, json, jsondecodeerror

Check r.headers['content-type'] or r.text before calling r.json() when an endpoint may return HTML. A local http.server returning 200 with Content-Type text/html and body '<html><body>hi</body></html>' made httpx.get(url).json() raise JSONDecodeError: 'Expecting value: line 1 column 1 (char 0)'. The error names no URL or content type, so it looks like a parsing bug. Tested with httpx 0.28.1, Python 3.12.3.
