Skip to content

JavaScript · browsers and Node.js

Expected ',' or '}' after property value in JSON at position N

JSON.parse throws Expected ',' or '}' after property value when it finishes a value inside an object and the next character is neither a comma nor the closing brace.

Updated · 2 min read

console
Chrome, Edge, Node.jsSyntaxError: Expected ',' or '}' after property value in JSON at position 47 (line 4 column 3)
Node.js 20SyntaxError: Expected ',' or '}' after property value in JSON at position 47
Node.js 18, older ChromeSyntaxError: Unexpected string in JSON at position 47
FirefoxSyntaxError: JSON.parse: expected ',' or '}' after property value in object at line 4 column 3 of the JSON data
SafariSyntaxError: JSON Parse error: Expected '}'

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 3, column 15

Missing comma between properties.

1{2  "name": "billing-worker",3  "port": 8080               ^4  "queue": "invoices",

Fix: Add ',' after the value on the highlighted line.

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

The position points at the first character after the value, here the quote that opens "queue" on line 4. The mistake sits just before it. Most common causes first:

1. A missing comma between properties. A line added to a config file by hand, or a block pasted from docs: in the sample, "port": 8080 has no comma. npm reports the same problem in a broken package.json:

npm error code EJSONPARSE
npm error JSON.parse Invalid package.json: JSONParseError: Expected ',' or '}' after property value in JSON at position 53 (line 4 column 3) while parsing near "...version\": \"1.0.0\"\n  \"private\": true\n}\n"

2. A double quote inside a string. In {"note": "Customer said "call after 5""} the string ends after said , and the parser finds c where a comma should be. This comes from building JSON by hand, for example with a template literal: `{"note": "${note}"}`.

3. A comment after a value. "port": 8080 // dev only fails at the /. JSON has no comment syntax; see Comments are not permitted in JSON.

4. A value JSON cannot read to the end. "timeout": 30s stops after 30, and hex like 0xFF stops after the 0. JSON numbers are plain decimals, so write 30 or the string "30s".

How to fix Expected ‘,’ or ‘}’ after property value

Put the comma after the previous value

Take the line and column from the message and step back to the end of the value before it. For the sample, line 4 column 3 means the comma goes after 8080 on line 3. The JSON validator marks that spot directly with Missing comma between properties.

Build JSON with a serializer

const note = 'Customer said "call after 5"';
const body = JSON.stringify({ note });   // {"note":"Customer said \"call after 5\""}

In Python, json.dumps({"note": note}) escapes the quotes the same way.

Let Repair add what is missing

JSON Repair adds the comma in the sample, escapes the inner quotes in the note example, strips comments and turns 30s into the string "30s". Read the result before you save it: Repair guesses at intent.

Same error in other languages

  • Python: json.decoder.JSONDecodeError: Expecting ',' delimiter: line 4 column 3 (char 47)
  • Go: invalid character '"' after object key:value pair
  • PHP: json_decode() returns null, and json_last_error_msg() says Syntax error.
  • VS Code: Expected comma (514) under the key that follows the missing comma.
  • Node.js 18: Unexpected string, or Unexpected number in JSON when a number follows the value.

For other parse errors, see common JSON errors.

Questions

Why does the position point at the line after the mistake?

The parser only knows a comma is missing when it reaches the next key. The comma belongs at the end of the value before it, often on the line above. The checker highlights that spot.

What does Expected ',' or ']' after array element mean?

The same mistake inside an array: two items with nothing between them, as in [1 2]. Add a comma after the first item.

Is a comma after the last property allowed?

No, but it fails differently: Chrome reports it as Expected double-quoted property name, because a key should follow every comma.

Related errors

All common JSON errors

Esc