# Missing comma in JSON: “Expected … after property value”

> Fix a missing comma in JSON: what “Expected ',' or '}' after property value” and “Expecting ',' delimiter” mean, and where the comma goes.

- URL: https://jsonstatham.dev/errors/missing-comma/
- Language: English (en)
- Russian version: https://jsonstatham.dev/ru/errors/missing-comma.md
- Updated: 2026-11-08

Two values, no comma. Somebody has to give. JSON separates every member of an object and every element of an array with a comma, and when one is missing the parser stops at the start of the next value, usually one line below the place you need to fix.

## The error and the fix

A new line was added at the end, and the line above it never got its comma:

```text
{
  "id": "op-0042",
  "status": "in progress"
  "eta_minutes": 12
}
```

Chrome reports `line 4 column 3`, Python `line 4 column 3`, and both point at `"eta_minutes"`. The comma belongs at the end of line 3:

```json
{
  "id": "op-0042",
  "status": "in progress",
  "eta_minutes": 12
}
```

Rule of thumb: when the error points at the beginning of a line, read the end of the line above it. The parser can’t know a comma is missing until it sees the next value begin.

## Why JSON needs a comma between values

[RFC 8259](https://www.rfc-editor.org/rfc/rfc8259#section-4) builds both containers from items and separators: “Elements are separated by commas” for arrays, and for objects “A single comma separates a value from a following name.” Whitespace and line breaks don’t separate anything in JSON; they are allowed around the structural characters and ignored. A line break where a comma should be is just whitespace, so two values end up side by side.

## Missing comma error messages by parser

Two one-line inputs: `{"a": 1 "b": 2}` and `[1 2]`. Every position below points at the second value, not at the gap before it.

| Parser | Object: {"a": 1 "b": 2} | Array: [1 2] |
| --- | --- | --- |
| Chrome, Edge, Node.js (V8) | `Expected ',' or '}' after property value in JSON at position 8 (line 1 column 9)` | `Expected ',' or ']' after array element in JSON at position 3 (line 1 column 4)` |
| Node.js 18, older Chrome (V8 10.2) | `Unexpected string in JSON at position 8` | `Unexpected number in JSON at position 3` |
| Firefox | `JSON.parse: expected ',' or '}' after property value in object at line 1 column 9 of the JSON data` | `JSON.parse: expected ',' or ']' after array element at line 1 column 4 of the JSON data` |
| Safari | `JSON Parse error: Expected '}'` | `JSON Parse error: Expected ']'` |
| Python | `Expecting ',' delimiter: line 1 column 9 (char 8)` | `Expecting ',' delimiter: line 1 column 4 (char 3)` |
| Go (encoding/json) | `invalid character '"' after object key:value pair` | `invalid character '2' after array element` |
| Java (Jackson 2) | `Unexpected character ('"' (code 34)): was expecting comma to separate Object entries` | `Unexpected character ('2' (code 50)): was expecting comma to separate Array entries` |
| C# (System.Text.Json) | `'"' is invalid after a value. Expected either ',', '}', or ']'.` | `'2' is invalid after a value. Expected either ',', '}', or ']'.` |
| C# (Newtonsoft.Json) | `After parsing a value an unexpected character was encountered: ". Path 'a', line 1, position 8.` | `After parsing a value an unexpected character was encountered: 2. Path '[0]', line 1, position 3.` |
| PHP (json_decode) | `Syntax error`, json_last_error() 4 | `Syntax error`, json_last_error() 4 |
| Rust (serde_json) | expected `,` or `}` at line 1 column 9 | expected `,` or `]` at line 1 column 4 |
| jq | `jq: parse error: Expected separator between values at line 1, column 11` | `jq: parse error: Expected separator between values at line 1, column 5` |
| RapidJSON | `Missing a comma or '}' after an object member.` | `Missing a comma or ']' after an array element.` |

Safari names the closing bracket it expected and leaves out the comma; Node.js 18 only says what kind of value surprised it. Checked by running: Node.js 18, 24 and 25.1, Safari 27, Python 3.9 and 3.14, Go 1.25–1.27, Jackson 2.22 (Jackson 3 words it the same), System.Text.Json and Newtonsoft.Json 13.0.4, PHP 8.3 and 8.5, serde_json 1.0, jq 1.7 and 1.8. Firefox and RapidJSON: from their source code; Firefox’s messages are also listed on [Mozilla’s reference pages](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/JSON_bad_parse).

## Where missing commas come from

- **A line added at the end** of an object or array. The mirror image of a [trailing comma](https://jsonstatham.dev/errors/trailing-comma/): the last line had no comma, the new last line doesn’t need one, and the old one now does.
- **Merges and copy-paste** of whole lines between files.
- **Arrays built in a loop** by appending each item with no separator, so `}{` ends up inside `[ ]`.
- **A double quote inside a string** that was never escaped. In `{"title": "The "Owl" case"}` the string ends after `The `, and Chrome reports the same “Expected ',' or '}'” at the word that follows. Escape it as `\"`.

Two values in a row at the top level, such as `{} {}` or one JSON object per line, are a different error: there is no container to separate them in. That is [extra data](https://jsonstatham.dev/errors/extra-data/).

## How to find a missing comma in code

The fix itself is one character. Finding it in a large document is the hard part, so the snippets below print the line above the reported position, where the comma most likely belongs.

### JavaScript

```js
const text = '{\n  "a": 1\n  "b": 2\n}';
try {
  JSON.parse(text);
} catch (e) {
  // V8 adds "(line L column C)" to the message (current Chrome, Node.js 24 and newer).
  const line = Number(/line (\d+)/.exec(e.message)?.[1]);
  console.log(text.split("\n")[line - 2]); //   "a": 1   (the comma goes at the end)
}
```

### Python

```python
import json

text = '{\n  "a": 1\n  "b": 2\n}'
try:
    json.loads(text)
except json.JSONDecodeError as e:
    print(e.msg, e.lineno, e.colno)         # Expecting ',' delimiter 3 3
    print(text.splitlines()[e.lineno - 2])  # the line above the error
```

### Go

```go
package main

import (
	"encoding/json"
	"errors"
	"fmt"
	"strings"
)

func main() {
	text := "{\n  \"a\": 1\n  \"b\": 2\n}"
	var v any
	err := json.Unmarshal([]byte(text), &v)
	var se *json.SyntaxError
	if errors.As(err, &se) {
		line := strings.Count(text[:se.Offset], "\n") + 1
		fmt.Println(err, "on line", line) // invalid character '"' after object key:value pair on line 3
	}
}
```

### Java (Jackson)

```java
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

String text = "{\n  \"a\": 1\n  \"b\": 2\n}";
try {
    new ObjectMapper().readTree(text);
} catch (JsonProcessingException e) {
    int line = e.getLocation().getLineNr(); // 3
    System.out.println(text.split("\n")[line - 2]); // the line above the error
}
```

### C#

```csharp
using System.Text.Json;

var text = "{\n  \"a\": 1\n  \"b\": 2\n}";
try {
    JsonDocument.Parse(text);
} catch (JsonException e) {
    // LineNumber counts from zero: 2 means the third line.
    var line = (int)e.LineNumber.GetValueOrDefault();
    Console.WriteLine(text.Split('\n')[line - 1]); // the line above the error
}
```

### PHP

```php
$text = "{\n  \"a\": 1\n  \"b\": 2\n}";
json_decode($text);
echo json_last_error_msg(); // Syntax error: no position at all
// PHP won’t say where; paste the text into a validator that will.
```

## How to stop losing commas

- Let a serializer write the separators; never join items with string concatenation.
- When editing by hand, add the comma to the old last line first, then the new line.
- Format the document after editing: with one member per line, a missing comma is easy to spot at the line ends.
- Check edits in the [JSON validator](https://jsonstatham.dev/validator/) or in CI before they reach production.

## Try it in the validator

[Open a sample with a missing comma](https://jsonstatham.dev/validator/?sample=missing_comma) in the JSON validator. It reports `missing_comma` at the value that should have been preceded by a comma and reminds you to look at the end of the previous line.

Related: [trailing comma](https://jsonstatham.dev/errors/trailing-comma/), [missing colon](https://jsonstatham.dev/errors/missing-colon/), [extra data](https://jsonstatham.dev/errors/extra-data/), [mismatched bracket](https://jsonstatham.dev/errors/mismatched-bracket/) (Chrome uses the same message for it), and all [JSON errors](https://jsonstatham.dev/errors/).

## Missing comma FAQ

### Why does the error point at the wrong line?

It points at the next value, because that is where the parser learns the comma is missing. Look at the end of the line before it.

### What does “Expected … after property value” mean in Chrome?

After a value inside an object, V8 can accept only a comma (another member follows) or `}` (the object ends). It found something else: usually the next key without a comma before it, sometimes an unescaped quote inside a string or a bracket of the wrong kind.

### What is “Unexpected string in JSON at position”?

The older V8 wording of the same error, still printed by Node.js 18: a string started where a comma or a closing bracket was expected.

### Can a line break replace a comma in JSON?

No. Line breaks are whitespace and carry no meaning in JSON. Only JSON Lines puts one value per line, and there are no commas between those values at all.
