2026-10-19 · 6 min read · Rahul Chitturi
- json
- api
- debugging
Flashman's JSON tool parses the text and prints it again. Pretty-print is JSON.stringify with two spaces, plus a trailing newline. Minify is JSON.stringify with no extra space and no trailing newline. Anything the parser cannot represent is already gone before the printer runs.
A diff that appears after formatting is not always a human edit. Negative zero, exponent notation, a duplicate key, and an escaped slash all change the text while the value a later JSON.parse sees stays in the same family.
Read the number the parser stored
The text -0 pretty-prints as 0 followed by a newline, and minifies as 0. The field {"n":-0} becomes {"n":0}. 1.0 becomes 1. 1e2 becomes 100. 1e20 becomes the 21-digit decimal 100000000000000000000. 1e21 becomes 1e+21, with an explicit plus. The same value can therefore move between a short exponent and a long decimal depending on its magnitude.
9007199254740993 becomes 9007199254740992. That integer is past the range JavaScript stores exactly, so the formatter and the number-bases tool agree on the rounded value. Compare the digits in the source with the digits in the output before you call the API wrong.
- Keep the original text beside the formatted text.
- Treat -0 and 0 as the same stored number.
- Expect 1e2 to print as 100 and 1e21 to print as 1e+21.
- Stop and widen the type when an integer longer than 16 digits changes.
Duplicate keys stay in the first slot
{"z":1,"a":1,"a":2,"m":3} formats with the keys z, a, m, and the value of a is 2. The second a is dropped. The first a keeps its position, so the object is not sorted alphabetically. A reviewer who reorders keys in their head will think the formatter sorted them. It preserved first-seen order and last-seen values.
An escaped slash is also text-only. {"s":"a\/b"} minifies to {"s":"a/b"}. The value is still a/b. A checksum of the bytes changes. A trailing comma, as in {"a":1,}, throws Expected double-quoted property name. A leading byte-order mark throws Unexpected token. The formatter does not strip either one.
Separate an empty box from a real value
Whitespace alone produces an empty output and no error, because the tool returns before parse when the trimmed box is empty. A root value is still JSON: true, null, and 1 all format. Pretty-print of 1 is the digit 1 plus one newline. Minify of 1 is the digit 1 and nothing after it. A diff between those two modes is that newline, not a data change.
Use the JSON tool when you need the canonical text, diff against the payload you received, and the MATLAB struct tool only after the numbers have stopped moving. The struct printer will show 1e+21 and 0 for inputs that were written as 1e21 and -0. Quote the source digits and the printed digits in the ticket.