Published January 2026 • 4 min read
JSON can be formatted in two very different ways: as pretty-printed, human-readable output with indentation, or as a minified, compact string with all unnecessary whitespace removed. Both have their place. Here is when to use each.
Pretty-printed JSON adds indentation and line breaks to make the structure easy to read at a glance:
{
"user": {
"id": 1,
"name": "Dinesh",
"active": true
}
}
Minified JSON strips all whitespace, resulting in a compact single-line string:
{"user":{"id":1,"name":"Dinesh","active":true}}
Both represent exactly the same data. The only difference is whitespace.
<script> tag or a data- attribute.package.json) should always be readable.For small objects the difference is minimal. But for large API payloads with deep nesting, minification can reduce file size by 20–40%. When combined with HTTP compression (gzip or Brotli), the savings compound further.
Use the JSON Pretty and JSON Minify tools on this site to instantly switch between the two formats for any JSON data.