Fix "Expecting value: line 1 column 1 (char 0)" (Python)
Python ยท JSON error
Opens the editor with a broken example loaded and repaired, entirely in your browser โ nothing is uploaded.
What causes it
json.loads() raises JSONDecodeError: Expecting value when the text it receives does not begin with a valid JSON value. "Line 1 column 1 (char 0)" means the problem is at the very first character, which almost always means the input is not JSON at all:
- Empty input โ
json.loads('')or a response with no body. - An HTML or plain-text response โ you called
response.json()on arequestsresult that returned an error page. Printresponse.textandresponse.status_codefirst. - Python literals, not JSON โ single quotes,
None,True/False, or a trailing comma copied from a Pythondict. Those are not valid JSON.
How to fix it
- Print repr(text) right before json.loads() to see whether it is empty or not JSON.
- For requests, check response.status_code and response.headers['content-type'] before calling .json().
- If the text uses single quotes, None, True or False, it is a Python literal โ convert to valid JSON (double quotes, null, true/false).
- Paste the text into JSON Wallet to convert Python-style pseudo-JSON into strict, valid JSON.
Before and after
Broken:
{'name': 'Ada', 'active': True, 'note': None}Fixed:
{"name": "Ada", "active": true, "note": null}Want to fix your own JSON instead of the example? Open the editor, paste it in, and click Repair โ it runs entirely in your browser.
Frequently asked questions
Why does char 0 mean the whole thing is wrong?
"char 0" is the first character. If the parser fails there, it never found a valid JSON value to begin with โ the input is empty or is not JSON, rather than having a small typo deeper in.
My data uses single quotes and True/False โ is that JSON?
No. That is a Python dict printed as a string. JSON requires double quotes and lowercase true/false/null. Convert it before parsing.
Related JSON errors
Fix JSON With Single Quotes
JSON only allows double quotes. Single quotes โ common when copying object literals from JavaScript or Python โ are rejected by every strict parser.
Fix "Unexpected token in JSON at position N"
The most common JSON.parse() error. It means the parser hit a character it did not expect โ usually HTML, an already-parsed object, or a stray token.
For a full reference of JSON mistakes, read Common JSON errors and how to fix them.