JSON errors

JavaScript, from JSON.parse()

Expected property name or '}' in JSON

Right after a { the parser needs either a double-quoted key or a closing }. Anything else stops it, which means the text is a JavaScript object literal or a JSON-like config, and strict JSON needs every key in double quotes.

How each browser and language words it

Chrome, Edge and Node 20+
SyntaxError: Expected property name or '}' in JSON at position 4 (line 2 column 3)
Older Chrome and Node 18 and below
SyntaxError: Unexpected token / in JSON at position 4
Firefox
SyntaxError: JSON.parse: expected property name or '}' at line 2 column 3 of the JSON data
Python
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 3 (char 4)

Paste your JSON to find the exact line

A JavaScript object pasted as JSON. Press Repair to quote the keys, swap the quotes and drop the comment.

Skip to editor
Explorer
Open Files

No files open

0 files open

jsoneditor.io v2

{
  // copied from a JavaScript file
  name: 'my-app',
  'version': '1.4.0',
  private: true,
}
JSONUTF-8
Spaces: 2

Causes and how to fix each one

1. Single quotes around keys or strings

{'name': 'my-app'} is a valid JavaScript object and valid Python, but JSON only accepts double quotes. Copying an object out of code or a Python print is the usual way this happens.

2. Keys without quotes

{name: "my-app"} works in JavaScript and not in JSON, where every key must be a double-quoted string.

3. Comments in the file

JSON has no comments, so // and /* */ lines make the parser stop at the slash. tsconfig.json and VS Code settings are JSONC and allow comments, which is why copying from them causes this. Strip the comments or press Repair.

Questions people ask

Can JSON use single quotes?

No. JSON strings and keys must use double quotes. Single quotes are a JavaScript and Python convention that JSON never adopted.

How do I convert a JavaScript object to JSON?

In code, JSON.stringify(object) gives you valid JSON. If you only have the text, paste it into the editor above and press Repair, it quotes the keys, converts single quotes and removes comments and trailing commas.

Tools for this