Quick answer
JSON requires every key to be a string in double quotes. Python raises json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes when it expects a key and finds anything else: a single quote, a bare word, or a closing brace after a trailing comma. Fix: create the text with json.dumps() instead of str(), remove trailing commas, and put double quotes around every key.
Example that fails
import json
data = {"name": "Ali"}
text = str(data) # "{'name': 'Ali'}" uses single quotes, not JSON
json.loads(text)
# json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
The message points at the exact spot. line 1 column 2 (char 1) is the character right after the opening brace, where the first key starts.
Common causes and fixes
1. Single quotes (a Python dict printed as text)
This is the most common cause. str(my_dict) and print(my_dict) produce Python syntax with single quotes, and True, False and None instead of true, false and null. That text is not valid JSON.
import json
data = {"name": "Ali", "active": True}
text = json.dumps(data) # '{"name": "Ali", "active": true}'
back = json.loads(text) # works
If you only have the Python-style text and cannot change the source, ast.literal_eval reads it safely and gives you a real dictionary. Unlike eval, it only accepts plain literals.
import ast, json
text = "{'name': 'Ali', 'active': True}"
data = ast.literal_eval(text) # a real Python dict
valid_json = json.dumps(data) # now it is valid JSON
2. A trailing comma
A comma after the last item makes the parser look for another key and find the closing brace.
json.loads('{"a": 1,}')
# JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 9 (char 8)
json.loads('{"a": 1}') # correct
Newer Python versions (3.13 and later) report this case with a clearer message about an illegal trailing comma. The fix is the same: delete the last comma.
3. Keys without quotes
JavaScript object literals allow {name: "Ali"}. JSON does not. Put double quotes around every key.
json.loads('{name: "Ali"}') # fails
json.loads('{"name": "Ali"}') # correct
4. A comment or stray text before the key
JSON has no comments. A // line or a note inside the braces is read as a key that is not quoted. Remove it, or strip comments before parsing.
The same error in JavaScript
JavaScript reports the same mistake with different wording:
- Chrome and Node.js:
Expected property name or '}' in JSON at position 1 - Trailing comma in Chrome and Node.js:
Expected double-quoted property name in JSON at position 8 - Firefox:
JSON.parse: expected double-quoted property name at line 1 column 2 of the JSON data
JSON.parse("{'name': 'Ali'}"); // fails: single quotes
JSON.parse('{"name": "Ali"}'); // correct
Find the exact spot
try:
data = json.loads(text)
except json.JSONDecodeError as e:
print(e.msg, "line", e.lineno, "column", e.colno, "char", e.pos)
print(repr(text[max(0, e.pos - 20):e.pos + 20]))
For a long document, paste it into the JSON Formatter to see the error highlighted, or into the JSON Repair tool, which fixes single quotes, trailing commas and unquoted keys automatically.
Have broken JSON right now?
Paste it into the free JSON Repair tool. It runs in your browser, so nothing is uploaded.
Open JSON Repair toolFAQ
Why does Python print a dict with single quotes?
Printing a dictionary shows Python syntax, not JSON. Python uses single quotes and writes True and None. Use json.dumps() whenever you need JSON text.
Can I make json.loads accept single quotes?
No. The standard library follows the JSON specification and rejects them. Convert the text with ast.literal_eval and json.dumps, or fix the source that creates it.
Is my JSON uploaded when I use Parsekit tools?
No. The tools run in your browser and nothing you paste is sent to a server.