Skip to content
TidyFizz

How to format and validate JSON without rounding large IDs

Use a JSON formatter that preserves the text of each number while changing indentation. This keeps long order IDs, database keys, and other exact values intact when you inspect an API response.

Why large IDs can change during formatting

Some formatters parse JSON into JavaScript values and then serialize it again. JavaScript’s Number type can represent every integer from −9,007,199,254,740,991 through 9,007,199,254,740,991 exactly. Beyond that safe range, some integers round to a neighboring value.

For example, an order ID of 9007199254740993 can become 9007199254740992 after a parse-and-serialize round trip. A formatter that preserves number tokens keeps the original digits in the output. Start with the raw response or original file when you have it, since a formatter cannot recover digits that an earlier step already changed.

Format and validate a sample JSON response

  1. Open the JSON Formatter. Paste {"orderId":9007199254740993,"status":"ready"} into JSON input, or use Open file to select an existing JSON file.
  2. Choose 2 spaces, 4 spaces, or Tabs, then select Format JSON.
  3. Check that orderId still shows 9007199254740993 on its own line. Use Copy result or Download to keep the formatted version.

To see a syntax error, add a comma after the last property before the closing brace and format again. Remove the trailing comma, then rerun the formatter. JSON property names and strings need double quotes. Check the formatter’s error message if the document still fails.

Check the receiving system too

Syntax validation checks whether the document follows JSON grammar. Use your API contract or a schema validator to check required fields, expected types, and accepted values.

If you control the API and its consumers, consider sending identifiers as strings, such as {"orderId":"9007199254740993"}. IDs identify records, so their exact characters usually matter more than arithmetic. If an existing API requires a numeric ID, follow its contract and use a reader that can preserve the required precision.

Minify when you need compact JSON

Use the JSON Minifier to remove formatting whitespace before sharing a compact payload. It preserves the digits in number tokens and keeps whitespace inside strings. For a debugging ticket or code review, keep the indented version so another reader can follow the structure.