Missing comma in JSON: Expected ',' or '}' after property value

Properties in an object and items in an array must be separated by commas. The parser finished one value and, instead of a comma or the closing bracket, found the start of something else. The reported position is the start of the next value, so the missing comma belongs at the end of the previous line. An unescaped double quote inside a string produces the same error, because it ends the string early.

Seen as:

  • SyntaxError: Expected ',' or '}' after property value in JSON at position 20 (line 3 column 3)
  • SyntaxError: Expected ',' or ']' after array element in JSON at position 68 (line 4 column 20)
  • SyntaxError: Unexpected string in JSON at position 20
  • SyntaxError: JSON.parse: expected ',' or '}' after property value in object at line 3 column 3 of the JSON data
  • json.decoder.JSONDecodeError: Expecting ',' delimiter: line 3 column 3 (char 20)

Input

Settings

History

Load from URL

Common causes

1. A new line added without a comma before it

Adding a property after the last one is easy to do without putting a comma on the line above. PasteKit reports it as “Missing comma after line N”, pointing at the line that needs it.

Before
{
  "name": "Ada"
  "email": "[email protected]"
}
After
{
  "name": "Ada",
  "email": "[email protected]"
}

2. Array items separated by spaces or newlines

Lists written one item per line, or copied from a spreadsheet column, often lack commas. Every item except the last needs one.

Before
{"tags": ["admin" "beta" "early-access"]}
After
{"tags": ["admin", "beta", "early-access"]}

3. Objects in an array written back to back

Concatenating records produces }{ or } followed by { on the next line. Separate them with commas inside the array.

Before
[
  {"id": 1}
  {"id": 2}
]
After
[
  {"id": 1},
  {"id": 2}
]

4. An unescaped double quote inside a string

In "The "Pro" plan" the quote before Pro closes the string, so the parser sees a finished value followed by the word Pro. Escape inner quotes as \".

Before
{"plan": "The "Pro" plan", "price": 49}
After
{"plan": "The \"Pro\" plan", "price": 49}

Frequently asked questions

Why is the error reported on the line after the missing comma?

The parser only knows a comma is missing when it reaches the next value, so the position is the start of that value. Look at the end of the previous line.

What did older browsers say for this error?

Before Chrome 117 and Node 20, V8 reported “Unexpected string in JSON” or “Unexpected number in JSON”, naming the type of the value that appeared where a comma should be.

Can Fix it insert missing commas?

Yes, between properties, array items and adjacent objects. It cannot always tell an unescaped quote from a missing comma, so check the diff when a string contains quotes.

Related