How to Format JSON Without Corrupting 64-Bit IDs or Decimal Precision
Many web-based JSON formatters silently alter large Snowflake IDs, financial decimals, and duplicate keys because they round-trip through JavaScript IEEE-754 numbers. Here is why that happens and how to inspect JSON safely.
Why JavaScript JSON.parse silently changes large numbers
JavaScript represents every regular number as an IEEE-754 double-precision floating-point value. That format can represent integers accurately only up to Number.MAX_SAFE_INTEGER, which is 9,007,199,254,740,991 (2^53 - 1). Modern APIs—such as distributed database keys, payment transaction IDs, and social platform Snowflake IDs—routinely exceed 16 digits.
When an online formatter runs JSON.parse(input) followed by JSON.stringify(parsed, null, 2), a value like 9007199254740993 silently turns into 9007199254740992 without raising an error. Similarly, fixed-scale decimals such as 19.50 or 1.2300 lose their trailing zeros, which can break diff reviews and financial test fixtures.
The hidden danger of duplicate object keys
The JSON specification (RFC 8259) notes that object member names should be unique, yet JavaScript’s native JSON.parse silently overwrites earlier keys with the last occurrence. In configuration files, webhook definitions, or permission policies, a duplicated key can hide a serious bug during code review.
Strict validation that rejects duplicate keys immediately lets you spot merge conflicts and copy-paste mistakes before deploying a broken config.
Token-preserving formatting vs. native parse-and-stringify
Instead of converting numeric text into floating-point binary values, a token-preserving JSON formatter scans the raw syntax grammar—strings, numbers, booleans, null, arrays, and objects—validates every rule strictly, and reprints the exact original number tokens with your chosen indentation.
- 64-bit integer tokens like 9007199254740993 remain character-for-character identical.
- Trailing decimal zeros like 1.2300 stay intact for clean visual diffs.
- Duplicate keys inside any object fail fast with exact line and column coordinates.
- Non-standard syntax such as comments, single quotes, and trailing commas are flagged rather than guessed.
Best practices when working with high-precision JSON APIs
Even if your formatter preserves exact numbers, downstream browsers or JSON clients may still round numeric fields when parsing responses. For newly designed APIs, serialize 64-bit IDs and exact monetary amounts as JSON strings (for example, "amount": "19.50" or "id": "9007199254740993").
When debugging existing third-party responses, format them in CreamTools JSON Formatter first, then compare before-and-after snapshots in TextDiff to verify only the intended fields changed.
Quick JSON review checklist
- Check whether any numeric ID has 16 or more digits before passing it through JavaScript JSON.parse.
- Reject duplicate object keys rather than relying on last-key-wins behavior.
- Remember that standard JSON forbids comments and trailing commas.
- Format locally in browser memory when inspecting private API payloads.
Try the related tools
Format, minify and validate JSON locally while preserving numeric tokens and rejecting duplicate keys.
Convert CSV and flat string JSON records locally, preserving postal codes and identifiers as strings.
Private in-browser line and word comparison highlighting additions, deletions, and edits.