Missing Comma in JSON: Fix the Previous Value

Understand why a JSON error can point after the mistake, and add the missing separator without changing your data.

A comma separates neighboring object members or array items. If it is missing, a parser often reports the next property or value because that is where the expected separator is absent.

Between object members

Invalid:

{
  "name": "Alex"
  "active": true
}

Add a comma after "Alex", before the next property:

{
  "name": "Alex",
  "active": true
}

Between array items

[1 2 3] needs separators: [1, 2, 3]. Newlines and spaces do not substitute for commas. If an array contains objects, the comma goes between their closing and opening braces: [{"id":1},{"id":2}].

Colon or comma?

A colon connects a property’s name and value, as in "id": 1. A comma separates that complete pair from the next pair. Adding a comma inside a pair will not fix a missing colon.

Use the validator to jump to the reported location. Inspect the preceding complete value, add its separator, and validate again. One error may cause several follow-on messages, so work from the first error downward.

Do not add a separator after the last item

An extra comma before } or ] creates a trailing comma error. A comma inside a quoted string, such as "Alex, Sam", is text and does not separate structural values.

If a response is cut off in transit, adding punctuation may conceal missing data. Check whether the document is complete before repairing it manually. The syntax guide explains the rest of the grammar; RFC 8259 defines the rules.

Already have valid JSON? Make it readable