JSON Problems

How to Pretty Print JSON in the Browser or Terminal

Pretty printing turns compact JSON into an indented layout that people can scan. The data stays the same. You can do it in an online formatter, from the command line or in code.

Last updated: 2 November 2026

Open JSON Formatter →

Step-by-step

  1. Paste the compact JSON into the JSON Formatter and run it to get two-space indentation.
  2. For a terminal, run python -m json.tool file.json or jq . file.json.
  3. In JavaScript, use JSON.stringify(value, null, 2) for a two-space layout.
  4. If you need the keys in a stable order, sort them first, for example with the sort-keys command in the JSON CLI.
  5. 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.

USE THE TOOL

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 →
FAQ

Frequently asked questions

What does pretty print mean?

It means formatting JSON with indentation and line breaks so it is easy for people to read.

Does pretty printing change the JSON?

No. It adds whitespace only, so the data is the same.

How do I pretty print JSON in the terminal?

Use python -m json.tool file.json or jq . file.json.

How do I make JSON compact again?

Use a JSON minifier, which removes the extra whitespace without changing the data.