Skip to content
configkit

Expected double-quoted property name in JSON

After a comma or an opening brace, JSON requires a key in double quotes. A trailing comma is the usual cause. A comment, a single quote, or an unquoted key produce the same error.

The message

The wording depends on what parsed the JSON:

  • Chrome, Edge, and current Node.js: Expected double-quoted property name in JSON at position 22
  • Older Chrome and Node.js: Unexpected token } in JSON at position 22
  • Firefox: JSON.parse: expected double-quoted property name
  • Python: Expecting property name enclosed in double quotes

The JSON formatter uses your browser's own parser, so it shows the same wording your browser would, with a line and column where the browser gives one.

Cause 1: a trailing comma

{
  "a": 1,
  "b": 2,
}

The comma after 2 promises another key, and the closing brace arrives instead. The error points at line 4, column 1. Delete the last comma. In an array such as [1, 2, 3,], the message names the bracket instead: Unexpected token ']'.

Cause 2: things JSON does not have

Each of these is valid JavaScript but not JSON. All three report Expected property name or '}' in Chrome.

{'a': 1}
{a: 1}
{
  // note
  "a": 1
}

Use double quotes for keys and strings, and remove comments. If you need notes in a config file, keep it in YAML or TOML and convert it. See Why comments disappear.

The opposite mistake

A missing comma between two keys gives a different message: Expected ',' or '}' after property value, pointing at the start of the second key.

{
  "a": 1
  "b": 2
}

The edge case

Some files that end in .json are not strict JSON. tsconfig.json and VS Code's settings.json accept comments and trailing commas, because those programs use a more lenient parser. package.json does not. Pasting a tsconfig.json with comments into a strict tool fails even though TypeScript reads it.

Paste the JSON into the JSON formatter to find the line. It never repairs input, so the output stays empty until the JSON is valid.