Single quotes in JSON: "Expected property name or '}'"
JSON only accepts double quotes. See the exact Chrome, Node.js and Python errors for single-quoted strings and how to convert them.
Error messages you may see
| Chrome · Edge · Node.js | SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) |
|---|---|
| Older Chrome · Node.js 18 and earlier | SyntaxError: Unexpected token ' in JSON at position 1 |
| Python json.loads | json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) |
| This tool | Line 1, Col 2: Strings and keys must use double quotes (") |
Why it happens
Keys and strings in JSON must use double quotes ("). Single quotes are valid in JavaScript and Python, so this usually happens when an object literal or a Python dict is copied as JSON.
Invalid
{'name': 'Kim', 'age': 30}
How to fix
Replace the single quotes around keys and strings with double quotes. In Python, create the text with json.dumps() instead of str() or print(). In JavaScript, use JSON.stringify().
Fixed
{"name": "Kim", "age": 30}
Open this example in the JSON formatter →
Tip: the formatter fixes this in one click with the 🔧 Auto-fix button.