Pretty print JSON

How to pretty print JSON

Pretty printing turns compact JSON into a readable structure with line breaks and indentation.

Example

Minified JSON:

{"user":{"id":42,"name":"Asha","active":true},"roles":["admin","editor"]}

Pretty printed JSON:

{
  "user": {
    "id": 42,
    "name": "Asha",
    "active": true
  },
  "roles": [
    "admin",
    "editor"
  ]
}

Best practices

When formatting breaks

If formatting fails, the JSON is likely invalid. Start here:

Validate JSON (common errors & fixes)

Related: Minify JSON · Sort JSON keys