JSON big integers

Client

Large integers in JSON may round when parsed as JavaScript numbers. Compare with a parser that keeps oversized integers as strings.

Learn more: precision beyond 2^53

Compare how standard `JSON.parse` rounds large integers versus a bigint-safe parser that keeps digits in strings—relevant for IDs and blockchain-style numbers.

JavaScript limits

IEEE doubles only represent integers exactly up to Number.MAX_SAFE_INTEGER. Anything larger may change when parsed naively—always validate in your target runtime.

Big integers

?

JavaScript JSON.parse only safely represents integers up to Number.MAX_SAFE_INTEGER. Larger values may lose precision. The second panel uses string-stored big integers for a faithful round-trip in text form.

Common use cases

  • Compare standard number parsing with bigint-safe parsing when IDs exceed Number.MAX_SAFE_INTEGER.
  • Debug APIs that return large integers as JSON numbers versus quoted strings.
  • Teach why financial or ledger identifiers should often be strings in JSON for interoperability.

Common mistakes to avoid

  • Assuming all runtimes parse big integers the same way

    JavaScript JSON.parse maps JSON numbers to IEEE doubles unless you use custom revivers or string storage. Other languages may differ—verify end-to-end.

  • Rounding in logs and then trusting the rounded value

    Once an ID rounds in the UI or a float, the damage is done. Treat oversized integers as opaque strings when exactness matters.

FAQ

Does this upload my JSON?

No. Parsing and comparison run entirely in your browser tab.

What is the safest representation for very large integers?

Often a decimal string in JSON, or a dedicated string field your backend documents—avoid silent float conversion.

Related utilities you can open in another tab—mostly client-side.