Expecting property name enclosed in double quotes

ErrorPython

json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 3 (char 4)

Where JSON.parse stops

{
  'name': 'Ada',
  'roles': ['admin', 'editor']

What it means

The parser was at a spot where a key has to begin, just after a { or just after a comma, and the next character was not a double quote. In JSON every key is a string, and every string is double-quoted. There is no second option.

Last verified on Python 3.9, 3.11, 3.12, 3.13 and 3.14.

It opens with the error marked. Nothing is uploaded. Find where the error is.

Usually
A printed Python dictA trailing comma before the closing braceUnquoted keysA comment inside the object
Fix
Put double quotes around every key and every string value, and delete any comma sitting before a } or ].

The fix

Put double quotes around every key and every string value, and delete any comma sitting before a } or ]. If the text came out of Python, generate it again with json.dumps(obj) rather than str(obj) or an f-string.

broken.jsonFails to parse
{
  'name': 'Ada',
  'roles': ['admin', 'editor']
}
JSON.parse stops at line 2, column 3.

Lines 2 and 3 change.

fixed.jsonParses
{
  "name": "Ada",
  "roles": ["admin", "editor"]
}
JSON.parse reads it.

How the message appears

The position given is where the key should have begun, not where the mistake was typed. A trailing comma gives this message on Python 3.12 and earlier. From Python 3.13 it gives Illegal trailing comma instead, and the position is the comma.

Console
  • json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 3 (char 4)
  • json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 4 column 1 (char 51)
  • json.decoder.JSONDecodeError: Illegal trailing comma before end of object: line 3 column 31 (char 49)
  • json.decoder.JSONDecodeError: Illegal trailing comma before end of array: line 1 column 3 (char 2)
  • json.decoder.JSONDecodeError: Expecting value: line 1 column 4 (char 3)

What causes it

  1. A printed Python dict

    str({'name': 'Ada'}) gives you {'name': 'Ada'}. It looks so close to JSON that it gets pasted into files and request bodies all day long. The single quotes are the giveaway. This is where the message comes from more often than anything else.

  2. A trailing comma before the closing brace

    On Python 3.12 and earlier, the comma promises another key and the } does not deliver one, so Python complains about the missing key instead of the comma. The column it reports is the closing brace, one line below the line you need to edit. From Python 3.13 the message is different and it points at the comma. In an array, 3.12 and earlier say Expecting value, and 3.13 and later name the comma. See Illegal trailing comma.

  3. Unquoted keys

    {name: "Ada"} is a perfectly good JavaScript object and not valid JSON. Anything copied out of JS source, a YAML file or a MongoDB shell lands here.

  4. A comment inside the object

    JSON has no comments. A # or // line between two keys puts the wrong character exactly where the parser was waiting for a quote.

Worth knowing

NoteIf what you have really is Python source and not JSON, ast.literal_eval is the right tool. It is not a JSON parser though, and it is not a substitute for one.

NotePython's error is more helpful than it first looks. The char offset is where the key should have started, so the mistake is almost always the character immediately before it.

What you put into the tools never leaves your browser. We count page views and keep them for 90 days. Accept and we also remember this browser, so a return visit is not counted as new. Privacy policy