Protect large identifiers when passing JSON through JavaScript

Distinguish valid JSON syntax from a value that survives browser parsing.

Digital Productivity2 min readPublished Last edited Automated editorial check:
On this page

JSON permits numbers whose exact values may exceed a reader's numeric representation. When a system uses a numeric-looking value as an identifier, preserving every digit matters more than whether an editor accepts the syntax.

Compare two otherwise identical records

Enter {"id":9007199254740993} into the ByeGA4 JSON Formatter. The current tool rejects the number because a JavaScript round trip would change its value. Now enter {"id":"9007199254740993"}. The quoted identifier can survive the round trip, and the formatted result still contains the original digits. The difference is a JSON type change, so confirm the downstream contract first.

A second example is {"reading":1e400}. Its number syntax is valid but a JavaScript parse can represent its value as infinity, which can later serialize as null. ByeGA4 rejects that case as well. This is a protective tool decision, not a declaration that all conforming JSON consumers must reject the source.

Decide how to retain exact values

If the receiving schema expects a numeric identifier beyond interoperable ranges, negotiate a lossless parser or change the contract before rewriting stored records. If the value is a measure rather than an identifier, agree on the precision and range that both systems support.

Create a test fixture with ordinary values, a very large identifier and a realistic decimal. Compare values on both sides of any API, export or conversion step. Syntax checks help at the input boundary, but a successful parse is only one part of verifying a cross-system data contract.

Reading and practice

Related guides

Search ByeGA4