JSON Errors / Python / JavaScript
Expecting property name enclosed in double quotesHow to Fix: Expecting property name enclosed in double quotes
JSON requires every object key to be wrapped in double quotes: {"name": "Ada"}. This error fires when a key is unquoted ({name: ...}), single-quoted ({'name': ...}), or when a trailing comma leaves the parser expecting another key that never comes.
The most common source: taking the string form of a Python dict (single quotes) or a JavaScript object literal (unquoted keys) and treating it as JSON. Those formats look like JSON but are not.
Common causes
1. Python dict string instead of JSON
str(my_dict) produces {'name': 'Ada'} with single quotes - not JSON. Use json.dumps(my_dict) to serialize.
{'name': 'Ada', 'age': 36}{"name": "Ada", "age": 36}2. JavaScript object literal syntax
In JS source code {name: "Ada"} is valid - but as a JSON document it is not, because the key lacks quotes.
{name: "Ada"}{"name": "Ada"}3. Trailing comma before the closing brace
After {"a": 1,} the parser expects another "key": value pair and instead finds } - reported as a missing property name.
{"a": 1,}{"a": 1}How to fix it
import json
data = {"name": "Ada", "age": 36}
text = json.dumps(data) # '{"name": "Ada", "age": 36}' - valid JSON
# If you are stuck with a dict-string from a log:
import ast
data = ast.literal_eval("{'name': 'Ada'}") # parse Python literal safelyconst obj = { name: "Ada" };
const text = JSON.stringify(obj); // '{"name":"Ada"}' - valid JSONFrequently asked questions
Why does JSON insist on double quotes for keys?
The JSON spec (RFC 8259) defines exactly one string syntax - double quotes - to keep parsers simple and interoperable. JavaScript object syntax is more permissive, but JSON was deliberately specified as a strict subset.
I have a file full of single-quoted "JSON". How do I convert it?
If it came from Python, parse it with ast.literal_eval() and re-serialize with json.dumps(). Avoid blind find-and-replace of quotes - it corrupts values that legitimately contain apostrophes or quotes.
Is JSON5 an option for relaxed syntax?
JSON5 allows unquoted keys, single quotes, comments, and trailing commas - useful for config files with a json5 parser library. But APIs and standard parsers expect strict JSON, so use JSON5 only where you control the parser.
Last updated:
Related JSON errors
You might also need
Free and in-browser, like everything on JSON Console. Browse all tools →