Skip to content
JSON Tidy
JSON errors

Expecting property name enclosed in double quotes

After an opening { or a comma inside an object, JSON expects a property name in double quotes. This error means the parser found something else there.

Usually the text is a Python dictionary or a JavaScript object literal. Both look like JSON, but they allow single quotes, unquoted names, and trailing commas.

Quick fix

  1. Look at the character at the reported position. It’s usually a single quote, the first letter of an unquoted name, or a } right after a comma.
  2. If your own code wrote the text, generate it with json.dumps() in Python or JSON.stringify() in JavaScript.
  3. For a one-off fix, paste it into the validator and choose Fix My JSON.

Find and fix it in the validator

Paste your broken JSON into the JSON validator. It underlines the first error as you type, and Fix My JSON repairs common mistakes such as missing quotes and extra commas. It runs in your browser, so your JSON isn’t uploaded.

This example has a single-quoted name, an unquoted name, Python’s True and None, and a trailing comma. Fix My JSON repairs all of them.

{
  'name': 'Maya',
  active: True,
  "manager": None,
}

The message in each browser and language

You might see any of these, depending on where the JSON is parsed:

WhereMessage
PythonJSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
Chrome, Edge, Node.js 20+Expected property name or '}' in JSON at position 1
Chrome, Edge, Node.js 20+ (trailing comma)Expected double-quoted property name in JSON at position 8
FirefoxJSON.parse: expected property name or '}' at line 1 column 2 of the JSON data
Older Chrome, Node.js 18Unexpected token ' in JSON at position 1

Common causes

  • Single quotes: {'name': 'Maya'}. This is how Python prints a dictionary.
  • Names without quotes: {name: "Maya"}. JavaScript allows this in code, and browser consoles display objects this way.
  • A trailing comma: {"a": 1,}. After the comma the parser expects another property name and finds }. See how to fix trailing commas.
  • A comment: // note or /* note */. Some config files, such as VS Code’s settings, use JSON with comments, but a strict JSON parser rejects them.

The position in the message points at the character that caused the error. char 1 or position 1 is the first character after {.

Fixing it in Python

If your program wrote the text, it probably used str(), print(), or an f-string on a dictionary. Those produce Python syntax. Use json.dumps to write JSON:

import json

data = {"name": "Maya", "active": True, "manager": None}

print(str(data))         # {'name': 'Maya', 'active': True, 'manager': None}  (not JSON)
print(json.dumps(data))  # {"name": "Maya", "active": true, "manager": null}

If you receive text in Python dictionary format and can’t change the sender, ast.literal_eval can read it safely. Then convert it to JSON:

import ast, json

text = "{'name': 'Maya', 'active': True, 'manager': None}"
data = ast.literal_eval(text)   # reads Python literals only; never runs code
print(json.dumps(data))

Avoid eval() for this, because it runs any code the text contains.

Fixing it in JavaScript

Build JSON with JSON.stringify(value) rather than template strings, so names are always quoted. If a config file is meant to have comments or unquoted names, read it with a JSON5 or JSONC parser, or convert it to strict JSON once.

For a one-off fix, use the validator’s Fix My JSON button. It’s built on the jsonrepair library, and it quotes names, changes single quotes to double quotes, removes comments and trailing commas, and turns True, False, and None into true, false, and null. Check the result before you use it.

Still stuck? Paste your JSON into the validator to see exactly where the first error is, or try Fix My JSON.

Sources and further reading