Skip to content
CalcLab

JSON Formatter

Validate and pretty-print (or minify) JSON.
No data
No results yetEnter values and run the tool to see results.

What is this calculator?

Validates JSON and re-prints it either indented for reading or minified to a single line. Because it parses before printing, a successful result is also a confirmation that the document is syntactically valid JSON.

Use it when:

  • You have an unreadable single-line API response and want to inspect it.
  • You want to confirm that a document is valid JSON before sending it somewhere.
  • You need to minify JSON to reduce its size.

Intended for: Developers debugging APIs, configuration files, or data payloads.

How is this calculated?

  1. The input is parsed into a value using the standard JSON parser; a syntax error is reported instead of a result, which is what makes this a validator as well as a formatter.
  2. The parsed value is then re-serialised — with the indent you choose, or with no whitespace at all in minify mode.
  3. Because output is produced from the parsed structure rather than by editing the text, the result is always canonically formatted and always valid.

Formula

Round trip

output = stringify(parse(input), indent)

Parsing then re-printing guarantees valid output and normalises inconsistent original formatting.

Example

Formatting `{"a":1,"b":[2,3]}` with a 2-space indent.

Result: A multi-line document with `"a": 1` and `"b"` as an indented array of 2 and 3.

Frequently asked questions

Does formatting change my data?

No. Only whitespace changes. The one thing to be aware of is that JSON numbers are parsed as double-precision floats, so a value beyond that precision may be re-printed differently.

Why does it reject my file?

Almost always a trailing comma, a single-quoted string, an unquoted key, or a comment. All four are valid JavaScript but not valid JSON.

Are object keys reordered?

No. Key order is preserved exactly as it appears in the input.

Assumptions

What this calculator takes as given:

  • The transformation is performed in your browser; the text you paste is not uploaded or stored.
  • Input is treated as UTF-8 text.
  • The input is intended to be strict JSON.

Limitations

What this calculator cannot know or does not model:

  • JSON5, JSONC (JSON with comments), and NDJSON are not supported.
  • Numbers beyond double-precision range may lose exactness on the round trip.
  • Very large documents are limited by available browser memory.

References