# Missing colon in JSON: “Expected … after property name”

> Fix a missing colon in JSON: what “Expected ':' after property name” and “Expecting ':' delimiter” mean, from = in place of : to a set in braces.

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

Key. Colon. Value. In that order. Inside a JSON object every key is followed by `:` and then its value; anything else after a key, whether `=`, `=>`, a bare value or a comma, stops the parser right there.

## The error and the fix

Three different habits, one error. Each line below fails at the character after the key:

```text
{"port" = 8080}
{"port" => 8080}
{"port" 8080}
```

The JSON way to write it is always the same:

```json
{"port": 8080}
```

The fourth habit is the sneaky one. `{"red", "green"}` looks like a list, but braces make an object, so `"red"` is read as a key and the comma after it as a missing colon. A list in JSON is an array: `["red", "green"]`.

## Why JSON needs the colon

[RFC 8259, section 4](https://www.rfc-editor.org/rfc/rfc8259#section-4): “A single colon comes after each name, separating the name from the value”, or in grammar form `member = string name-separator value`, where the name separator is `:`. There is no shorthand: no key without a value, no other separator, no implicit value of `true`.

## Missing colon error messages by parser

The value right after the key, `{"a" 1}`, and an equals sign in place of the colon, `{"a" = 1}`:

| Parser | {"a" 1} | {"a" = 1} |
| --- | --- | --- |
| Chrome, Edge, Node.js (V8) | `Expected ':' after property name in JSON at position 5 (line 1 column 6)` | `Expected ':' after property name in JSON at position 5 (line 1 column 6)` |
| Node.js 18, older Chrome (V8 10.2) | `Unexpected number in JSON at position 5` | `Unexpected token = in JSON at position 5` |
| Firefox | `JSON.parse: expected ':' after property name in object at line 1 column 6 of the JSON data` | `JSON.parse: expected ':' after property name in object at line 1 column 6 of the JSON data` |
| Safari | `JSON Parse error: Expected ':' before value in object property definition` | `JSON Parse error: Expected ':' before value in object property definition` |
| Python | `Expecting ':' delimiter: line 1 column 6 (char 5)` | `Expecting ':' delimiter: line 1 column 6 (char 5)` |
| Go (encoding/json) | `invalid character '1' after object key` | `invalid character '=' after object key` |
| Java (Jackson 2) | `Unexpected character ('1' (code 49)): was expecting a colon to separate field name and value` | `Unexpected character ('=' (code 61)): was expecting a colon to separate field name and value` |
| C# (System.Text.Json) | `'1' is invalid after a property name. Expected a ':'.` | `'=' is invalid after a property name. Expected a ':'.` |
| C# (Newtonsoft.Json) | `Invalid character after parsing property name. Expected ':' but got: 1. Path '', line 1, position 5.` | `Invalid character after parsing property name. Expected ':' but got: =. Path '', line 1, position 5.` |
| PHP (json_decode) | `Syntax error`, json_last_error() 4 | `Syntax error`, json_last_error() 4 |
| Rust (serde_json) | expected `:` at line 1 column 6 | expected `:` at line 1 column 6 |
| jq | `jq: parse error: Expected separator between values at line 1, column 7` | `jq: parse error: Invalid numeric literal at line 1, column 7` |
| RapidJSON | `Missing a colon after a name of object member.` | `Missing a colon after a name of object member.` |

This is one of the few errors that almost every parser names correctly. The exceptions are old V8, which describes the token it didn’t expect, and jq, whose “separator” means a colon here. For the set-like `{"red", "green"}`, Chrome and Python give the same missing-colon messages, pointing at the comma. 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 says “property name”), 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 a missing colon comes from

- **`=` from other formats**: `.ini` and `.env` files, shell variables, URL query strings.
- **`=>` from code**: PHP arrays and Ruby hashes printed with `inspect` look almost like JSON.
- **A set or a list in braces**: Python sets, C# collection initializers and many configuration languages use `{a, b}` for a list.
- **A key with its value missing**, for example after a find-and-replace removed `: null` or a template printed an empty value. A key directly followed by `}` gets reported the same way.

## How to produce the colon in code

The usual cause in code is text from another format being passed off as JSON. Parse it with the tools for that format, build a map, and let the serializer write the colons; for collections, make sure a set becomes an array.

### JavaScript

```js
// key=value lines: build an object, then let JSON.stringify write the colons.
const lines = "debug=true\nport=8080".split("\n");
console.log(JSON.stringify(Object.fromEntries(lines.map((l) => l.split("="))))); // {"debug":"true","port":"8080"}

// A Set has no keys of its own: JSON.stringify writes {} for it.
const colors = new Set(["red", "green"]);
console.log(JSON.stringify(colors), JSON.stringify(Array.from(colors))); // {} ["red","green"]
```

### Python

```python
import json

colors = {"red", "green"}  # a set: braces, but no keys
try:
    json.dumps(colors)
except TypeError as e:
    print(e)  # Object of type set is not JSON serializable
print(json.dumps(sorted(colors)))  # ["green", "red"]
```

### Go

```go
package main

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

func main() {
	pairs := map[string]string{}
	for _, line := range strings.Split("debug=true\nport=8080", "\n") {
		k, v, _ := strings.Cut(line, "=")
		pairs[k] = v
	}
	b, _ := json.Marshal(pairs)
	fmt.Println(string(b)) // {"debug":"true","port":"8080"}
}
```

### Java (Jackson)

```java
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

Set<String> colors = new TreeSet<>(List.of("red", "green"));
System.out.println(new ObjectMapper().writeValueAsString(colors)); // ["green","red"]
```

### C#

```csharp
using System.Text.Json;

var colors = new SortedSet<string> { "red", "green" };
Console.WriteLine(JsonSerializer.Serialize(colors)); // ["green","red"]
```

### PHP

```php
$config = ['debug' => true, 'port' => 8080]; // PHP writes key => value
echo json_encode($config);                    // {"debug":true,"port":8080}
```

## How to keep colons where they belong

- Don’t convert formats by search and replace: `=` to `:` breaks on the first value that contains `=`.
- When a value is unknown, write `null`, not nothing.
- Use `[ ]` for lists, `{ }` only for key-value pairs.
- Run hand-edited files through the [JSON validator](https://jsonstatham.dev/validator/) before committing them.

## Try it in the validator

[Open a sample with a missing colon](https://jsonstatham.dev/validator/?sample=missing_colon) in the JSON validator. It reports `missing_colon` at the character that stands where `:` should be and shows what it found there.

Related: [missing comma](https://jsonstatham.dev/errors/missing-comma/), [unquoted key](https://jsonstatham.dev/errors/unquoted-key/), [trailing comma](https://jsonstatham.dev/errors/trailing-comma/), and all [JSON errors](https://jsonstatham.dev/errors/).

## Missing colon FAQ

### Can I use = instead of : in JSON?

No. The colon is the only separator between a key and its value. `=` belongs to `.ini` and `.env` files and to query strings.

### Can a JSON key have no value?

No. Every key needs a value; write `null` if there isn’t one. A key on its own is reported as a missing colon.

### Why is {"red", "green"} a missing colon and not a list?

Braces always open an object in JSON, and an object holds key-value pairs. The parser reads `"red"` as a key and expects a colon after it. Lists use square brackets.
