What the error means
json.loads and json.load expect a value (an object, array, string, number, true, false or null) at the current position and found something else. "line 1 column 1 (char 0)" means that happened at the first character of the text, so the whole text is the problem, not a typo deep inside it. A larger position, such as "line 5 column 12 (char 80)", points at a place later in the document where a value was expected, for example after a comma or a colon.
The validator above runs a different parser, so its wording is different ("Unexpected token" for the HTML sample it opens with), but it stops at the same character.
The usual causes at char 0
Print the text before parsing it (print(repr(text))) and match what you see against these cases.
Empty string or empty response
Error: Expecting value: line 1 column 1 (char 0)
Invalid
import requests, json response = requests.get(url) # 204 No Content, or an error with no body data = response.json()
Fixed
response = requests.get(url)
response.raise_for_status()
data = response.json() if response.content else {}An empty body is not JSON. Check the status code and that the body has content before parsing. The same happens when json.loads receives "" from an empty file or an unset variable.
An HTML page instead of JSON
Error: Expecting value: line 1 column 1 (char 0)
Invalid
<!DOCTYPE html> <html><body>404 Not Found</body></html>
Fixed
{"status": "ok"}A wrong URL, an expired login or a rate limit usually returns an HTML error or sign-in page. Print response.status_code and response.text[:200] to see it, then fix the URL, headers or credentials.
File read twice
Error: Expecting value: line 1 column 1 (char 0)
Invalid
with open(path) as f:
print(f.read())
data = json.load(f) # the file pointer is at the endFixed
with open(path) as f:
text = f.read()
data = json.loads(text)f.read() moves the file pointer to the end, so json.load(f) then reads an empty string. Read once and parse that string, or call f.seek(0) first.
Python values rather than JSON
Error: Expecting value: line 1 column 2 (char 1)
Invalid
['a', 'b'] # also: None, True, False
Fixed
["a", "b"] # null, true, false
str() or print() of a Python list or dict produces Python syntax. Single quotes, None, True and False are not JSON. Produce the text with json.dumps(value) instead.
Trailing comma in an array (Python before 3.13)
Error: Expecting value: line 1 column 4 (char 3) (Python 3.13: Illegal trailing comma before end of array)
Invalid
[1, 2,]
Fixed
[1, 2]
JSON allows no comma after the last item. Older Python versions report it as a missing value at the closing bracket; 3.13 names the trailing comma.