Skip to content

noJsonUnsafeValues (JSON)

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

Disallow unsafe JSON values that may cause interoperability issues.

Some JSON values can break when parsed by different tools or languages as parser implementations & data types could differ. For example, a very large number might become Infinity in JavaScript, or a string with an incomplete Unicode pair might fail to decode properly.

The common unsafe values are:

  • Lone surrogates in strings: Incomplete Unicode character pairs that can cause encoding/decoding failures
  • Numbers that evaluate to Infinity: Values like 1e400 that exceed JavaScript’s number range
  • Unintentional zeros: Very small numbers (e.g., 1e-400) that silently evaluate to zero due to precision limitations
  • Unsafe integers: Numbers outside JavaScript’s safe integer range (±2^53-1) that lose precision
  • Subnormal numbers: Very small floating point values that may be handled differently across systems

These issues can lead to data corruption, silent failures, or inconsistent behavior across different platforms and languages.

{
"invalid1": 2e308
}
code-block.json:2:15 lint/nursery/noJsonUnsafeValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The number will evaluate to Infinity.

1 │ {
> 2 │ "invalid1": 2e308
^^^^^
3 │ }
4 │

Certain values can cause interoperability issues between different parsers and environments. Replace this value with a safe alternative.

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.

{
"invalid2": -2e308
}
code-block.json:2:15 lint/nursery/noJsonUnsafeValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The number will evaluate to Infinity.

1 │ {
> 2 │ "invalid2": -2e308
^^^^^^
3 │ }
4 │

Certain values can cause interoperability issues between different parsers and environments. Replace this value with a safe alternative.

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.

{
"invalid3": "\ud83d"
}
code-block.json:2:15 lint/nursery/noJsonUnsafeValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Lone surrogate found.

1 │ {
> 2 │ "invalid3": "\ud83d"
^^^^^^^^
3 │ }
4 │

Certain values can cause interoperability issues between different parsers and environments. Replace this value with a safe alternative.

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.

{
"invalid4": 1e-400
}
code-block.json:2:15 lint/nursery/noJsonUnsafeValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The number will evaluate to zero.

1 │ {
> 2 │ "invalid4": 1e-400
^^^^^^
3 │ }
4 │

Certain values can cause interoperability issues between different parsers and environments. Replace this value with a safe alternative.

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.

{
"invalid5": 9007199254740992
}
code-block.json:2:15 lint/nursery/noJsonUnsafeValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The integer is outside the safe integer range.

1 │ {
> 2 │ "invalid5": 9007199254740992
^^^^^^^^^^^^^^^^
3 │ }
4 │

Certain values can cause interoperability issues between different parsers and environments. Replace this value with a safe alternative.

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.

{
"invalid6": 2.2250738585072009e-308
}
code-block.json:2:15 lint/nursery/noJsonUnsafeValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Unexpected subnormal number found, which may cause interoperability issues.

1 │ {
> 2 │ "invalid6": 2.2250738585072009e-308
^^^^^^^^^^^^^^^^^^^^^^^
3 │ }
4 │

Certain values can cause interoperability issues between different parsers and environments. Replace this value with a safe alternative.

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.

[
123,
1234,
12345, // Regular numbers within safe range
"🔥", // Properly formed Unicode character (fire emoji)
"\ud83d\udd25", // Same character with proper surrogate pair
0.00000,
0e0000000,
0.00000e0000 // Zero represented in different valid ways
]