What the error means
A JSON object has to start with a double-quoted key. The parser found something else where a key should be, usually a single quote or a bare word, so it complains that it expected a property name or the closing brace.
The message looks like this in Chrome, Edge and Node.js (Firefox and Safari use different wording for the same problems):
Expected property name or '}' in JSON at position 1 (line 1 column 2)
Unexpected token ' in JSON at position 1 (older Chrome and Node.js)Common causes
Single quotes instead of double quotes
JSON allows only double quotes, for keys and for string values. JavaScript, Python and many config formats allow single quotes, so text copied from them is not valid JSON.
Broken: {'name': 'Ada'}
Valid: {"name": "Ada"}Unquoted keys
A JavaScript object literal does not need quotes around simple keys. JSON does.
Broken: {name: "Ada", age: 36}
Valid: {"name": "Ada", "age": 36}Text copied from console.log or a Python print
Printing an object shows a human-friendly form with single quotes, and Python also prints True, False and None. These are not JSON. Generate the text with JSON.stringify in JavaScript or json.dumps in Python instead of copying printed output.
Broken: {'active': True, 'manager': None}
Valid: {"active": true, "manager": null}A trailing or leading character
An invisible byte-order mark or a stray character before the opening brace can also trigger this. Delete anything before the first {.
How to find the problem
- Paste the text that you passed to JSON.parse into the editor above. The status bar shows the line and column of the first problem, and Go to error jumps there.
- Remember that the position in the message is where the parser gave up, which is often one token after the real mistake. Look at the character before it as well.
- If the text came from a request, log the raw response text before parsing it. In the browser, open the Network tab, select the request and read the Response tab.
Produce valid JSON instead of copying printed output
// JavaScript
const text = JSON.stringify({ name: "Ada", active: true, manager: null });
# Python
import json
text = json.dumps({"name": "Ada", "active": True, "manager": None})Frequently asked questions
Does JSON allow single quotes anywhere?
No. Strings and keys must use double quotes. A single quote is only valid inside a double-quoted string, for example "it's fine".
Can I convert a JavaScript object to JSON automatically?
Yes: press Fix JSON, which rewrites single quotes and unquoted keys. In code, build the data as an object and call JSON.stringify.