Format JSON without changing large numbers
Why formatting should preserve numeric literals, and how to handle duplicate keys and strict validation.
ToolMellow ·
Formatting is not data conversion
A formatter should make source easier to read without silently changing its values. JavaScript Number cannot exactly represent every integer beyond 9007199254740991. Parsing a larger integer into Number and serializing it again can therefore change the source value.
Keep the source tokens
ToolMellow validates JSON and applies whitespace edits to the original source. It does not round-trip the document through JSON.stringify for formatting. Numeric spellings such as 9007199254740993 and 1e+20 are preserved. Minify removes insignificant whitespace while keeping the same tokens.
Resolve duplicate keys deliberately
A JSON object can contain repeated member names in source, but consumers handle them differently and commonly keep the last value. The formatter warns about duplicate keys without choosing which one to delete. Review the original source and decide which data is intended.
Use strict JSON where strict JSON is required
Comments, trailing commas, and single-quoted strings are not accepted by this validator. An error includes a line and column. The tool does not execute pasted text or silently repair it; fix the indicated problem and validate again.
Check the consumer too
Preserving a literal here cannot change how a downstream application parses it. If your API needs exact identifiers or decimal arithmetic, choose an appropriate schema and parser in that application. A formatted document alone is not proof of end-to-end precision.