{ }JSON Workbench

Formatting versus minifying JSON

Formatting adds indentation and line breaks around JSON values. Minifying removes optional whitespace outside strings. Both aim to represent the same parsed data.

Format while you inspect

Indentation makes nested objects and arrays easier to follow. Two spaces are compact, four spaces make levels more distinct, and tabs follow your editor’s tab width. Pick a consistent style for files your team reviews.

Minify when size matters

Readable:
{
  "status": "ready",
  "count": 3
}

Minified:
{"status":"ready","count":3}

Minification preserves spaces inside string values. It is not gzip compression and it will not shorten keys or remove fields. A server can compress either representation separately.

Sorting keys is optional

Sorting may help you compare similarly structured objects. It does not normalize every aspect of JSON and is not a cryptographic canonicalization algorithm. Do not use the output as a signing format unless your protocol explicitly specifies the same rules.

Parsing can change text

JavaScript parsing and serialization may normalize number notation and Unicode escapes. Duplicate object properties collapse to the final value. Large integers can lose precision. If exact byte representation matters, retain the source rather than assuming formatting is lossless.

Format or minify a document →