Step-by-step
- Paste the compact JSON into the JSON Formatter and run it to get two-space indentation.
- For a terminal, run python -m json.tool file.json or jq . file.json.
- In JavaScript, use JSON.stringify(value, null, 2) for a two-space layout.
- If you need the keys in a stable order, sort them first, for example with the sort-keys command in the JSON CLI.
- Minify the result again before sending it over a network if size matters.
When to pretty print
Pretty printing is useful for reading API responses, comparing configuration files in version control and writing documentation examples. Consistent indentation and key order also make differences between two files easier to see.
When not to
Pretty printed JSON is larger because of the extra whitespace. For network responses and stored data where size matters, send the minified version. The data is identical either way.
Keep sensitive data safe
JSON often contains tokens, email addresses or customer data. Avoid pasting secrets into any online tool, and remove or replace sensitive values first.
Finish the task with DevUtilityKits
Use the relevant online utility, check the result, and continue with your development workflow.
Open JSON Formatter →Open JSON Minifier →Open JSON CLI →