JSON format
Reformat a JSON document (or paste it in) as pretty-printed or minified JSON.
Working…
Questions people ask
- Will the output be *exactly* the same JSON?
- Yes, in the RFC 8259 value sense: every object, array, string, number, boolean and null is preserved, and the order of keys inside each object is preserved unless you turn on "sort keys". Whitespace is, of course, the thing you asked to change. Numbers are re-spelled in their canonical JSON form (`1.50` becomes `1.5`), which is not a value change. Strings are emitted with the same characters, including non-ASCII (UTF-8, not escaped with back-\\u). One deliberate guard: a number literal beyond the 64-bit float range (`1e400`, legal JSON but not re-emittable through a float formatter without becoming the non-JSON token `Infinity`) is refused with the named `E_JSON_FLOAT_RANGE` reason instead of being silently mangled.
- Why was my document refused for E_JSON_FLOAT_RANGE when it is valid JSON?
- It is, and the tool says so honestly: the number token (``1e400``-style, legal RFC 8259) has a value bigger than a 64-bit float can hold, and this formatter serialises numbers through 64-bit floats. Re-emitting it as ``Infinity`` would produce text that is not JSON, so rather than corrupt your document the tool completes the attempt and hands back the named reason (with the token) on a succeeded job. Fix the literal's scale, or use the minify/pretty result of a decimal-aware formatter for that rare case.
- What if my document is not valid strict JSON?
- The tool does not crash, and it does not guess. Instead it completes the attempt and gives you a downloadable diagnosis: a syntax error with the parser's line and column, a Python-only constant (`NaN`, `Infinity`), a repeated key in an object (reformatting would silently drop the earlier value, which is not what you asked for), or nesting more than 512 levels deep. The status cell reads "Could not format" and the reason sits in the findings table below it. You do not download a reformatted file for a document the tool could not prove was faithful; that would be the fuzzy formatter behaviour we would rather refuse. Think of it as "a lint that also tells you how to make the reformat possible", not "a lint that is the reformat".
- Why does the tool not just "best-effort" like some formatters?
- Some formatters take a broken document, silently drop the offending value, and hand back "something that looks like your input". This tool refuses to do that: it would rather hand back an unformatted document plus a named reason. If you want a validation of the document, the sibling JSON lint tool is the right one; it will tell you every issue at once. This tool stops at one fatal, because fixing one error changes the document, so the next pass should see the real state.
- Does anything leave my server?
- No. The processor runs in an isolated container with no network access: it is a stdlib `json` invocation plus a short pre-scan of the nesting depth. The upload is deleted the moment the job completes; the result is kept for about 10 minutes.