Skip to content

JavaScript · browsers and Node.js

Expected double-quoted property name in JSON at position N

Expected double-quoted property name in JSON appears when a comma inside an object is followed by } or anything other than another "key".

Updated · 2 min read

console
Chrome, Edge, Node.jsSyntaxError: Expected double-quoted property name in JSON at position 83 (line 5 column 1)
Node.js 20SyntaxError: Expected double-quoted property name in JSON at position 83
Node.js 18, older ChromeSyntaxError: Unexpected token } in JSON at position 83
FirefoxSyntaxError: JSON.parse: expected double-quoted property name at line 5 column 1 of the JSON data
SafariSyntaxError: JSON Parse error: Property name must be a string literal

Find it in your JSON

Paste the text that failed. The checker points at the exact spot, and Repair fixes most syntax mistakes.

Input · JSON

Invalid JSON

Line 4, column 36

Trailing comma before '}'.

2  "name": "billing-worker",3  "port": 8080,4  "queues": ["invoices", "refunds"],                                    ^5}

Fix: JSON does not allow a comma after the last property. Delete it.

Why this happens
Invalid JSONRuns in your browser

Load from a URL

Your browser fetches it directly, so the server must allow cross-origin requests (CORS).

Why it happens

A comma inside an object promises one more "key": value pair, and the parser reports the first character after it. In the sample, Chrome points at the } on line 5, while the mistake is the comma at the end of line 4; the checker highlights the comma itself. Causes, likeliest first:

1. A trailing comma before }. You deleted or moved the last property, or copied the object from JavaScript, where that comma is legal.

2. A commented-out last property.

{
  "host": "db.internal",
  "port": 5432,
  // "ssl": true
}

Two problems at once: the comma after 5432 and the comment. Chrome reports the / at line 4, column 3.

3. An unquoted or single-quoted key after the first one. {"sku": "PEN-7", qty: 3} fails on the q. On the first key, the same mistake gives Expected property name or ‘}’.

4. JSON built by string concatenation. A loop that writes a comma after every item leaves one before the closing brace:

const limits = { cpu: 2, memoryMb: 512 };
let json = '{';
for (const [key, value] of Object.entries(limits)) {
  json += `"${key}": ${value},`;
}
json += '}';   // {"cpu": 2,"memoryMb": 512,}

How to fix Expected double-quoted property name

Delete the comma

Remove the comma after the last property. In a long file, go to the reported line and check the end of the line above. The JSON validator shows it as Trailing comma before '}', and JSON Repair removes every trailing comma and comment in one pass.

Stop building JSON by hand

A serializer never writes a trailing comma:

const json = JSON.stringify(limits);

Config files that people edit

To allow trailing commas and comments in a hand-edited file, parse it as JSONC:

import { readFileSync } from 'node:fs';
import { parse } from 'jsonc-parser';

const errors = [];
const config = parse(readFileSync('worker.json', 'utf8'), errors, { allowTrailingComma: true });
if (errors.length) throw new Error(`worker.json has ${errors.length} syntax error(s)`);

jsonc-parser never throws, so check the errors array. Keep files that other programs read in strict JSON. For comments, see Can JSON have comments?

Same error in other languages

  • Firefox uses the same words: JSON.parse: expected double-quoted property name.
  • Python 3.13+: JSONDecodeError: Illegal trailing comma before end of object: line 4 column 36 (char 81) for the sample, pointing at the comma. Older versions say Expecting property name enclosed in double quotes at the character after it.
  • Go: invalid character '}' looking for beginning of object key string.
  • VS Code marks the comma as Trailing comma, and comments as Comments are not permitted in JSON.

For other messages, see common JSON errors.

Questions

Why does JavaScript allow the comma when JSON does not?

JavaScript added trailing commas to its own syntax. JSON's grammar separates members with commas and has no rule for one after the last member, and the ECMA-404 standard says that grammar is not expected to change.

Does a trailing comma in an array give the same message?

No. [1, 2,] fails with Unexpected token ']', "[1, 2,]" is not valid JSON, because after a comma in an array the parser expects a value, not a key.

Is a trailing comma allowed in package.json?

No. npm reads package.json as strict JSON and stops with an EJSONPARSE error. tsconfig.json is different: TypeScript accepts trailing commas and comments there.

Related errors

All common JSON errors

Esc