## The JavaScript 64-Bit Integer Problem
In JavaScript, all numbers are double-precision floats (IEEE 754). The maximum safe integer is `Number.MAX_SAFE_INTEGER` (`9007199254740991` or `2^53 - 1`).
When a database or microservice (written in Java, Go, or Rust) returns a 64-bit integer ID like `9223372036854775807`, standard `JSON.parse()` silently rounds the last digits:
const raw = '{"id": 9223372036854775807}';
console.log(JSON.parse(raw).id);
// Output: 9223372036854776000 (WRONG ID due to float precision loss!)Solution 1: Return 64-bit IDs as Strings from API
The cleanest industry fix is to format 64-bit database IDs as strings in your backend API JSON responses:
{
"id": "9223372036854775807"
}Solution 2: Use json-bigint Parser Library
If you cannot alter the backend API source code, use `json-bigint` in Node.js:
const parsed = JSONbig.parse('{"id": 9223372036854775807}'); console.log(parsed.id); // "9223372036854775807" (Preserved string!) ```
--- Format and inspect raw API payloads with our browser tools!