← Back to the JSON tool

Pretty-Print JSON

Last updated: 26 September 2026

Pretty-printing means rewriting JSON with indentation and line breaks so a person can read it. Here is a box that does it in your browser, followed by the one-liners for terminals, editors and code.

Runs locally No upload Keeps key order

What changes and what does not

Pretty-printing inserts whitespace between tokens: line breaks, indentation, and a space after each : and ,. Nothing else moves. Property order is preserved, string contents are untouched — including spaces inside them — and no numbers are rounded. Parse the file before and after and you get identical data, which is why minifying and pretty-printing are reversible operations on the same document.

Pretty-print JSON in a terminal

For files too large or too sensitive to paste into a browser:

All three read stdin, so a live API response works without saving it first:

When you only want one branch of a big document, filter instead of scrolling: jq '.limits' config.json prints just that object, and jq -r '.regions[]' lists array items one per line.

Pretty-print inside your code

In an editor

VS Code: paste, then Shift+Option+F on macOS or Shift+Alt+F on Windows and Linux to format the document; set "editor.tabSize": 2 to control the width. IntelliJ and WebStorm: Cmd+Option+L (Ctrl+Alt+L) to reformat. Sublime Text needs a package such as Pretty JSON. Most editors will refuse to format a file with a syntax error, so fix the error first — the validator reports the line and column.

When you should not pretty-print

Pretty output is bigger — often 20–45% bigger, and more for deeply nested data — so sending it over the network costs real bytes on every request. Anything a machine consumes should stay compact: API responses, bundled assets, localStorage values. Minify those instead, and keep indentation for files a human reads and reviews in a diff.

Two other cases worth knowing: a several-megabyte document will make a browser tab or editor crawl, so slice it with jq rather than opening it whole; and if the goal is comparing two payloads, sort the keys first — the formatter's recursive key sort puts two files in the same order so a diff shows only real changes.

Frequently Asked Questions

What does pretty-printing JSON do?

It rewrites JSON with line breaks and indentation, one value per line, so a human can read the structure. Only formatting whitespace is added: the data, key order and every string value stay exactly as they were, and parsing the pretty version gives the same result as parsing the original.

How do I pretty-print JSON in a terminal?

With jq: run jq '.' file.json to print it indented. Without jq, python3 -m json.tool file.json does the same job, and node -e with JSON.parse plus JSON.stringify using a two-space indent works too. Any of them can read a pipe, so curl -s https://api.example.com/data | jq . pretty-prints a live response.

Why does my pretty-printed JSON have escaped unicode?

Some writers escape every non-ASCII character by default — Python's json.dump turns an accented letter into a six-character \uXXXX escape. Pass ensure_ascii=False to keep the real characters, which stays valid JSON and is far easier to read.

Should pretty-printed JSON be committed to Git?

Yes, when people edit the file, because a diff of one-property-per-line JSON shows exactly what changed. The opposite is true for generated payloads: minify what crosses the network and keep formatted JSON for anything a human reads.