Python JSONDecodeError: Expecting value
A plain-words explanation of this Python message: what it means, the usual causes, and the steps that fix it.
The messagejson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Make the error yourself
Run with Python 3.14.10. This is the smallest example we could find that shows it.
Python program (main.py)
import json
text = ""
data = json.loads(text)
print(data)Output (the real message)
Traceback (most recent call last):
File "main.py", line 4, in <module>
data = json.loads(text)
File "<Python folder>\Lib\json\__init__.py", line 352, in loads
return _default_decoder.decode(s)
~~~~~~~~~~~~~~~~~~~~~~~^^^
File "<Python folder>\Lib\json\decoder.py", line 345, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "<Python folder>\Lib\json\decoder.py", line 363, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)Why it happens
json.loads was given text that is not valid JSON. "Expecting value: line 1 column 1 (char 0)" means that at the very first character it found no valid value. Common reasons: the text is empty (a failed request, an empty file), the server sent an HTML error page (it starts with <), the text uses single quotes ({'a': 1} is Python, not JSON), or there is a stray character such as a byte-order mark. Other variants: "Expecting property name enclosed in double quotes" (single quotes or a trailing comma) and "Extra data" (two JSON documents in one text).
How to fix it
- Print the raw text before parsing:
print(repr(text[:200])). You will usually see the problem at once. - If it came from a web request, check the status code first and look at the content.
- JSON needs double quotes around keys and strings, and no trailing commas.
- Wrap the parse in
tryandexcept json.JSONDecodeError.
The corrected version
Python program (main.py)
import json
text = '{"name": "Asha"}'
try:
data = json.loads(text)
except json.JSONDecodeError as err:
data = None
print("Not valid JSON:", err)
print(data)Output (the corrected version)
{'name': 'Asha'}How to avoid it
Check that a response is successful before you parse it, and keep a copy of the raw text in your log for failures.
Questions
How do I parse a Python dictionary printed with single quotes?
Do not use JSON for that; use ast.literal_eval(text), which reads Python literals safely.
This is an independent guide. It is not connected with Python, Microsoft, Google, GitHub or the Git project. Product names belong to their owners. Examples were run on 13 November 2026 in a practice folder or a blank workbook; your version may word a message slightly differently.