Skip to content

noEmptyObjectKeys (JSON)

Language JSON (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"noEmptyObjectKeys": "error"
}
}
}
}

Disallow empty keys in JSON objects.

JSON allows empty strings as object keys, but they are difficult to identify in logs, error messages, and source code. This rule reports keys that are empty or contain only whitespace, because they are usually accidental. Use a short, meaningful name instead.

{
"": "value"
}
code-block.json:2:3 lint/nursery/noEmptyObjectKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Unexpected empty object key.

1 │ {
> 2 │ "": "value"
│ ^^
3 │ }
4 │

ℹ Empty keys often cause confusion and may cause issues with parsers or processors. Either remove this property or provide a meaningful key name.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

{
"validKey": "value",
"": "another value"
}
code-block.json:3:3 lint/nursery/noEmptyObjectKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Unexpected empty object key.

1 │ {
2 │ "validKey": "value",
> 3 │ "": "another value"
│ ^^
4 │ }
5 │

ℹ Empty keys often cause confusion and may cause issues with parsers or processors. Either remove this property or provide a meaningful key name.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

{
" ": "space as key"
}
code-block.json:2:3 lint/nursery/noEmptyObjectKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Unexpected empty object key.

1 │ {
> 2 │ " ": "space as key"
│ ^^^
3 │ }
4 │

ℹ Empty keys often cause confusion and may cause issues with parsers or processors. Either remove this property or provide a meaningful key name.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

{
"\t": "tab as key"
}
code-block.json:2:3 lint/nursery/noEmptyObjectKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Unexpected empty object key.

1 │ {
> 2 │ "\t": "tab as key"
│ ^^^^
3 │ }
4 │

ℹ Empty keys often cause confusion and may cause issues with parsers or processors. Either remove this property or provide a meaningful key name.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

{
"\n": "newline as key"
}
code-block.json:2:3 lint/nursery/noEmptyObjectKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Unexpected empty object key.

1 │ {
> 2 │ "\n": "newline as key"
│ ^^^^
3 │ }
4 │

ℹ Empty keys often cause confusion and may cause issues with parsers or processors. Either remove this property or provide a meaningful key name.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

{
"key": "value"
}