JSON errors

JavaScript, from JSON.parse(), and Firefox

Expected double-quoted property name in JSON

After a comma the parser expects another "key": value pair. When it finds a closing } instead, it reports that it was expecting a property name, which is the parser's way of saying there's a trailing comma.

How each browser and language words it

Chrome, Edge and Node 20+
SyntaxError: Expected double-quoted property name in JSON at position 111 (line 7 column 3)
Older Chrome and Node 18 and below
SyntaxError: Unexpected token } in JSON at position 111
Firefox
SyntaxError: JSON.parse: expected double-quoted property name at line 7 column 3 of the JSON data
Python 3.13+
json.decoder.JSONDecodeError: Illegal trailing comma before end of object: line 6 column 26 (char 107)

Paste your JSON to find the exact line

Both trailing commas are underlined. Press Repair to remove them.

Skip to editor
Explorer
Open Files

No files open

0 files open

jsoneditor.io v2

{
  "name": "my-app",
  "version": "1.4.0",
  "scripts": {
    "dev": "next dev",
    "build": "next build",
  },
  "private": true,
}
JSONUTF-8
Spaces: 2

Causes and how to fix each one

1. A trailing comma after the last property

JavaScript, TypeScript and most config formats allow a comma after the last item, so it slips into JSON files all the time, especially package.json, tsconfig.json and VS Code settings copied around. JSON does not allow it. Delete the comma before the closing brace, or press Repair above.

2. A trailing comma in an array

The same thing in an array gives a slightly different message in Chrome and Node, Unexpected token ']', "[1,2,]" is not valid JSON. The fix is the same, remove the comma before the ].

3. Generated JSON built with string concatenation

Code that adds a comma after every item in a loop leaves one dangling at the end. Build the data as an object or array and let JSON.stringify write the commas.

JavaScript
// leaves a trailing comma
let json = '{'
for (const [key, value] of entries) json += `"${key}": "${value}",`
json += '}'

// always valid
const json = JSON.stringify(Object.fromEntries(entries))

Questions people ask

Does JSON allow trailing commas?

No. The JSON standard (RFC 8259) has no trailing commas anywhere. JSON5 and JSONC, the format VS Code uses for its settings, do allow them, but JSON.parse and every strict parser will reject them.

How do I find the trailing comma in a big file?

Paste the file into the editor above. The error is underlined on the exact line, and the position in the error message counts characters from the start of the file, starting at 0.

Tools for this