Skip to content

noEmptyObjectKeys (JSON)

Language JSON (and super languages)
biome.json
{
"linter": {
"rules": {
"suspicious": {
"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/suspicious/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.

{
"validKey": "value",
"": "another value"
}
code-block.json:3:3 lint/suspicious/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.

{
" ": "space as key"
}
code-block.json:2:3 lint/suspicious/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.

{
"\t": "tab as key"
}
code-block.json:2:3 lint/suspicious/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.

{
"\n": "newline as key"
}
code-block.json:2:3 lint/suspicious/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.

{
"key": "value"
}