Common causes
1. 64-bit IDs sent as JSON numbers
BIGINT primary keys, snowflake IDs and payment references routinely exceed 2^53. Send them as strings; an ID is never used for arithmetic anyway.
{"orderId": 1234567890123456789}{"orderId": "1234567890123456789"}2. Parsing in JavaScript without a reviver
When you cannot change the producer, read the original digits. Modern engines (Chrome 114+, Node 21+) pass the source text to the reviver, so large integers can become BigInt.
const order = JSON.parse(text);const order = JSON.parse(text, (key, value, context) =>
typeof value === 'number' && !Number.isSafeInteger(value) && /^-?\d+$/.test(context.source)
? BigInt(context.source)
: value,
);3. Serializing BigInt values
Once you hold a BigInt, JSON.stringify throws “Do not know how to serialize a BigInt”. Convert it explicitly, usually to a string.
const body = JSON.stringify({ orderId: 1234567890123456789n });const body = JSON.stringify({ orderId: 1234567890123456789n }, (key, value) =>
typeof value === 'bigint' ? value.toString() : value,
);4. Decimal amounts and trailing zeros
Floats also drop formatting: 129.90 parses to 129.9, and values with more than about 15 significant digits are rounded. For money, send integer minor units or a decimal string.
{"total": 129.90, "rate": 0.1234567890123456789}{"totalCents": 12990, "rate": "0.1234567890123456789"}Frequently asked questions
What is the largest safe integer in JSON?
JSON itself has no limit, but JavaScript and many other parsers use 64-bit floats, which are exact up to 9,007,199,254,740,991 (Number.MAX_SAFE_INTEGER). Treat anything larger as unsafe unless every consumer uses a big-number parser.
Does Python lose precision too?
No for integers: Python’s json module parses them as arbitrary-size int. Floats still become 64-bit doubles unless you pass parse_float=decimal.Decimal.
Will PasteKit change my numbers when formatting?
No. The formatter copies number text exactly, so 1234567890123456789 and 129.90 come out as written. Conversions such as JSON to YAML or CSV also keep the original digits.