Skip to content

useConsistentObjectKeys (JSON)

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

Enforce JSON keys with consistent Unicode representation.

Unicode characters can have different internal representations that look identical. For example, “é” can be stored as one code point (U+00E9) or as “e” plus a combining accent (U+0065 + U+0301). Unicode normalization converts text to a standard form (such as NFC) so visually identical keys share the same representation. This avoids confusing behavior in JSON objects where equality checks and key lookups should treat matching text consistently.

More on Unicode normalization can be found here.

Select the Unicode representation that keys must follow.

Default: NFC

NFC: Canonical Decomposition followed by Canonical Composition

biome.json
{
"linter": {
"rules": {
"nursery": {
"useConsistentObjectKeys": {
"level": "on",
"options": {
"form": "NFC"
}
}
}
}
}
}
{
"caf\u0065\u0301": "espresso"
}
code-block.json:2:5 lint/nursery/useConsistentObjectKeys  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This object key mixes Unicode characters that can be encoded in more than one way.

1 │ {
> 2 │ "caf\u0065\u0301": "espresso"
^^^^^^^^^^^^^^^^^
3 │ }
4 │

Characters that look identical can have different byte representations, so such keys may fail to compare as equal.

Rewrite the key so equivalent characters use a single, consistent Unicode encoding.

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.

Unsafe fix: Rewrite the key using a consistent Unicode encoding.

1 1 {
2 - ····"caf\u0065\u0301":·"espresso"
2+ ····"café":·"espresso"
3 3 }
4 4

NFD: Canonical Decomposition

biome.json
{
"linter": {
"rules": {
"nursery": {
"useConsistentObjectKeys": {
"level": "on",
"options": {
"form": "NFD"
}
}
}
}
}
}
{
"\u00C5": "precomposed A-ring"
}
code-block.json:2:5 lint/nursery/useConsistentObjectKeys  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This object key mixes Unicode characters that can be encoded in more than one way.

1 │ {
> 2 │ "\u00C5": "precomposed A-ring"
^^^^^^^^
3 │ }
4 │

Characters that look identical can have different byte representations, so such keys may fail to compare as equal.

Rewrite the key so equivalent characters use a single, consistent Unicode encoding.

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.

Unsafe fix: Rewrite the key using a consistent Unicode encoding.

1 1 {
2 - ····"\u00C5":·"precomposed·A-ring"
2+ ····"Å":·"precomposed·A-ring"
3 3 }
4 4

NFKC: Compatibility Decomposition followed by Canonical Composition

biome.json
{
"linter": {
"rules": {
"nursery": {
"useConsistentObjectKeys": {
"level": "on",
"options": {
"form": "NFKC"
}
}
}
}
}
}
{
"\u00BD": "circled digit one"
}
code-block.json:2:5 lint/nursery/useConsistentObjectKeys  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This object key mixes Unicode characters that can be encoded in more than one way.

1 │ {
> 2 │ "\u00BD": "circled digit one"
^^^^^^^^
3 │ }
4 │

Characters that look identical can have different byte representations, so such keys may fail to compare as equal.

Rewrite the key so equivalent characters use a single, consistent Unicode encoding.

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.

Unsafe fix: Rewrite the key using a consistent Unicode encoding.

1 1 {
2 - ····"\u00BD":·"circled·digit·one"
2+ ····"12":·"circled·digit·one"
3 3 }
4 4

NFKD: Compatibility Decomposition

biome.json
{
"linter": {
"rules": {
"nursery": {
"useConsistentObjectKeys": {
"level": "on",
"options": {
"form": "NFKD"
}
}
}
}
}
}
{
"\u00BD": "vulgar fraction one half"
}
code-block.json:2:5 lint/nursery/useConsistentObjectKeys  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This object key mixes Unicode characters that can be encoded in more than one way.

1 │ {
> 2 │ "\u00BD": "vulgar fraction one half"
^^^^^^^^
3 │ }
4 │

Characters that look identical can have different byte representations, so such keys may fail to compare as equal.

Rewrite the key so equivalent characters use a single, consistent Unicode encoding.

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.

Unsafe fix: Rewrite the key using a consistent Unicode encoding.

1 1 {
2 - ····"\u00BD":·"vulgar·fraction·one·half"
2+ ····"12":·"vulgar·fraction·one·half"
3 3 }
4 4