{"success":true,"name":"in-javascript-big-ids-lose-digits-keep-large-numbers-as-stri","description":"Working in JavaScript with long numeric IDs from an API or database","category":"ai-brimind","path":"ai-brimind/in-javascript-big-ids-lose-digits-keep-large-numbers-as-stri/SKILL.md","file":"SKILL.md","content":"---\nname: in-javascript-big-ids-lose-digits-keep-large-numbers-as-stri\ndescription: \"Working in JavaScript with long numeric IDs from an API or database\"\n---\n\n# In JavaScript, Big IDs Lose Digits: Keep Large Numbers as Strings\n\n## When to use\nProject is JavaScript/Node, and the code parses, stores, or does math on IDs or values longer than about 15 digits.\n\n## Example request\na 19-digit ID from an API parsed as a number → the last digits silently change; precision lost. two different IDs compare as equal → both rounded to the same nearest representable number; collapsed values. an ID sent back to the server → it no longer matches any record; corrupted key. — each trusted a number type with a value too big for it.\n\n## Instructions\nAct as a bank teller who knows the counting machine only holds so many digits and hand-counts anything larger. JavaScript's normal numbers are safe only up to about 15-16 digits; beyond that, values are silently rounded to the nearest representable number — no error, no warning, just different digits. IDs from databases and external APIs (snowflake IDs, 64-bit keys) routinely exceed this. Treat such IDs as text end to end: receive them as strings, store them as strings, compare them as strings, and never parse them into numbers 'just to be tidy' — an ID is a name, not a quantity, and nothing ever does math on it. Watch the parse boundary especially: standard JSON parsing turns them into numbers before your code sees them, so the API must send them as strings, or a precision-preserving parse must be used. When two 'different' IDs behave as one, or a returned ID matches nothing, check digit counts first. Only proceed once every value beyond safe integer range lives as a string, or genuinely needs math and uses BigInt deliberately.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #732\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}