Skip to content
All guides

A little guidance

How to format JSON without rounding big numbers

Many formatters change long IDs such as 12345678901234567890. JSON Prettifier keeps every digit, every decimal and every key exactly as written.

Advertisements

Format JSON exactly

A 20-digit order ID stays exact

We pasted a payment record with a 20-digit orderId, a 20-digit tracking number and an amount of 1250.00. In the tree, every digit and the trailing zeros were unchanged.

The payment record as a tree showing orderId 12345678901234567890, trackingNumber 98765432109876543210 and amount 1250.00 unchanged.
Long numbers keep every digit. View full size
ValueMany formattersJSON Prettifier
123456789012345678901234567890123456700012345678901234567890
987654321098765432109876543210987654000098765432109876543210
1250.0012501250.00

The numbers in the middle column are what JavaScript’s JSON.parse produces.

Repeat this example

  1. Paste the JSON with long numbers.
  2. Look at it in the tree, or minify it.
  3. Compare the numbers with the original.

Check the result

orderId still ends in …567890 and amount still reads 1250.00.

A common mistake

Checking in another tool afterwards: if that tool rounds, the change happens there, not here.

Open JSON Prettifier

Sources and credits

Sample JSON made for these guides. The bookshop orders, names and emails are invented. Every screenshot shows the real tool working on that JSON.

Why numbers change elsewhere

JavaScript can store whole numbers exactly only up to 9,007,199,254,740,991. Tools that read JSON with it round longer IDs, so 12345678901234567890 can turn into 12345678901234567000.

What JSON Prettifier does

It reads JSON with its own parser that keeps the original text of every number, so long IDs, trailing zeros such as 1250.00 and exponents stay exactly the same, in the tree and in what you copy or save.

Other things that stay

Escapes in strings, the order of keys and even repeated keys are kept. Repeated keys are mentioned in the line at the bottom, because most programs keep only the last one.

Check it yourself

Paste JSON with a long ID, look at it in the tree or minify it, and compare: only spaces and line breaks change.

  • JSON Prettifier

    How to sort JSON keys alphabetically

    Press the A–Z button in the Preview toolbar to order the keys of every object in your JSON, which makes two files much easier to compare.

Advertisements