JSON number precision-loss test file
Integers and decimals that exceed IEEE-754 double precision: 64-bit IDs, high-precision decimals, and values at MAX_SAFE_INTEGER boundaries.
↓ Download precision-loss.json| Filename | precision-loss.json |
| Format | JSON |
| Size | 319 bytes (319 bytes) |
| MIME type | application/json |
| SHA-256 | 7075086fd6d6809ccd379203d3d4f803c22d4c44593b109f0032b1a8b9ba2e08 |
Handle it in code
Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.
Node.js
JSON.parse turns every number into a double, so integers above 2^53 change silently. In recent Node versions the reviver also receives the original source text, which lets you keep them exact as BigInt.
const fs = require('node:fs');
const data = JSON.parse(fs.readFileSync('precision-loss.json', 'utf8'), (key, value, ctx) =>
typeof value === 'number' && !Number.isSafeInteger(value) && /^-?\d+$/.test(ctx?.source ?? '')
? BigInt(ctx.source)
: value);
console.log('oneAbove:', data.oneAbove);
console.log('snowflakeId:', data.snowflakeId);Run against this file, it prints: oneAbove: 9007199254740993n
snowflakeId: 1234567890123456789n
Python
Python integers are exact at any size, so only decimals can lose precision. parse_float=Decimal keeps them as written.
import json
from decimal import Decimal
with open("precision-loss.json", encoding="utf-8") as f:
data = json.load(f, parse_float=Decimal)
print("oneAbove:", data["oneAbove"])
print("highPrecisionDecimal:", data["highPrecisionDecimal"])Run against this file, it prints: oneAbove: 9007199254740993
highPrecisionDecimal: 0.1234567890123456789