Test files › Structured data › precision-loss.json

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
Filenameprecision-loss.json
FormatJSON
Size319 bytes (319 bytes)
MIME typeapplication/json
SHA-2567075086fd6d6809ccd379203d3d4f803c22d4c44593b109f0032b1a8b9ba2e08
What this file catchesThe classic JavaScript bug where a 64-bit database ID arrives as 9007199254740992 instead of ...993. Any client parsing this into a double corrupts the values silently. Correct handling means parsing large integers as strings or BigInt.

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

Related guides and tools

Sample JSON fileJSONL and how it breaksCharacter encodingsVerify its SHA-256

Download & verify

curl -fsSL -o "precision-loss.json" "https://files.hexaqa.com/json/precision-loss.json"
curl -fsSL "https://files.hexaqa.com/json/precision-loss.json" | sha256sum # expect: 7075086fd6d6809ccd379203d3d4f803c22d4c44593b109f0032b1a8b9ba2e08

More structured data test files

deeply-nested-100000.jsonlarge-array-100mb.jsonmalformed-trailing-comma.jsonndjson-10000-lines.ndjsonvalid-small.jsonbillion-laughs.xmlunclosed-tag.xmlvalid.xml

← All Structured data files