Oriel — AI & technology worth noticing, every day.

🔢 The JSON Numbers JavaScript Quietly Corrupts

Web page · https://prettify.tools/blog/the-json-numbers-javascript-corrupts

JSON.parse changes your data and never says so. Three distinct failure modes, only one of which is the famous one about large integers.

First seen by Oriel on .

AI summary

The page explains how JavaScript silently changes JSON numbers during parsing and serialization, and describes Prettify’s token-preserving approach for exact viewing and round-tripping.

  • JavaScript’s IEEE-754 numbers provide 53 bits of integer precision, so JSON integers above 9007199254740991 can be silently rounded.
  • Values such as 1e400 become Infinity when parsed and null when serialized, changing both their representation and type.
  • JSON.stringify also changes formatting, turning 4.0 into 4, 1.00 into 1, -0 into 0, and 5e+3 into 5000.
  • Prettify preserves the original numeric token when either its value or formatting would change, while keeping safely round-tripping numbers as ordinary JavaScript numbers.
  • Viewing and round-tripping remain exact, but arithmetic, aggregation, and comparison coerce wrapped values to floats and notify the user.

#javascript #json #number precision #lossless parsing

Generated by gpt-5.6-sol. Check the original for details.

Metric trends

Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained

Reactions

Total public reactions reported by the source; distinct from points and likes.

  • DEV Community: 13, latest observation ; +2 over observed period since

Comments

Comment count reported by the source.

  • DEV Community: 6, latest observation ; +3 over observed period since

Aliases

SourceExternal IDURL
DEV Community4905877https://prettify.tools/blog/the-json-numbers-javascript-corrupts Read discussion