The exact message
print(data) writes for a dict (the worked example below){'name': 'Ada', 'active': True, 'manager': None}- Chrome, Edge, Node.js
SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2)- Firefox
SyntaxError: JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data- Safari
SyntaxError: JSON Parse error: Single quotes (') are not allowed in JSON
{name: "Ada"}- Chrome, Edge, Node.js
SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2)- Firefox
SyntaxError: JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data- Safari
SyntaxError: JSON Parse error: Expected '}'
}{"a": 1,}- Chrome, Edge, Node.js
SyntaxError: Expected double-quoted property name in JSON at position 8 (line 1 column 9)- Firefox
SyntaxError: JSON.parse: expected double-quoted property name at line 1 column 9 of the JSON data- Safari
SyntaxError: JSON Parse error: Property name must be a string literal
Measured in Chrome 158, Firefox 159, Safari's engine (WebKit 27.2) and Node.js 22. Edge uses the same engine as Chrome.
Right after {, Chrome and Firefox say “Expected property name or '}'”: an object may be empty or start with a
property name. After a comma they say “Expected double-quoted property name”, because another property has to follow,
so a } is wrong there too. Safari words each case differently.
What it means
In JSON, every property name is a string in double quotes: {"name": "Ada"}. At the position in the message there's
something else: a single quote, a letter, a comment, or the closing } right after a comma.
What causes it
- Python's
print(data)orstr(data)of a dict. It looks like JSON but uses single quotes andTrue,FalseandNone. - A JavaScript object literal, copied from source code or the browser console: property names without quotes, often with single quotes and trailing commas too.
- A trailing comma after the last property:
{"a": 1,}. JavaScript allows it, JSON doesn't. - A comment right after
{, as in a config file. - JSONC config files (with comments and trailing commas, like
tsconfig.jsonor VS Code'ssettings.json) read with a plain JSON parser.
How to find the spot
Position 1 is the character right after the first {, so the very first property name is already wrong; Firefox
calls it “line 1 column 2”. A later position points at the property that isn't quoted, or at the } after a trailing
comma. Paste the text into the JSON Formatter: it marks the spot and says which problem it is, for
example “property names must use double quotes, not single quotes”.
How to fix it
Write JSON with a JSON library instead of printing the data. In Python, that's json.dumps:
import json
data = {"name": "Ada", "active": True, "manager": None}
print(data) # {'name': 'Ada', 'active': True, 'manager': None}
print(json.dumps(data)) # {"name": "Ada", "active": true, "manager": null}
In JavaScript, it's JSON.stringify, which quotes every property name:
JSON.stringify({ name: "Ada", active: true });
// {"name":"Ada","active":true}
Config files with comments need a parser that supports them (JSONC or JSON5), not JSON.parse. For a one-off,
press Fix it in the JSON Formatter: it quotes property names, changes single quotes to double quotes and removes
comments and trailing commas, and lists every change.
Worked example
What Python's print writes for a dict:
The input
{'name': 'Ada', 'active': True, 'manager': None}- Chrome and Node.js say
SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2)- The JSON Formatter says
- Hmm, something's off on line 1, column 2: property names must use double quotes, not single quotes 🤔
Press “Fix all 6” and the JSON Formatter makes these changes:
- Changed single quotes to double quotes in 4 strings (line 1)
- Changed True, False or None to true, false or null in 2 places (line 1)
The result:
{"name": "Ada", "active": true, "manager": null}The result is exactly what json.dumps writes for the same dict. When you control the code that prints it, use
json.dumps and you won't need the repair.