Digital ToolPad.

Runs 100% in your browser

Your data never leaves your device. zero uploads.

Beautify JSON in one click, or in one line of code

JSON Pretty Print

Paste compact JSON or open a .json file and pretty print it with 2 spaces, 4 spaces or tabs. Prefer to do it in code? Copy a ready-made one-liner for Python, JavaScript, jq or your terminal below.

How it works

Valid JSON

Loading...

121 B1 linedepth 3Processed in your browser

What does pretty printing JSON mean?

Pretty printing, also called beautifying or prettifying, adds line breaks and indentation to JSON so that every property sits on its own line and nested objects are indented under their parent. The data does not change. Only the whitespace between tokens does, which is why pretty-printed and minified JSON parse to exactly the same value.

This JSON beautifier validates your text first, then writes it out with the indentation you choose. You can also sort keys alphabetically, which is handy when comparing two documents.

How to pretty print JSON online

  1. 1

    Add JSON

    Paste compact JSON or press Open file. The example in the editor is a single line you can try.

  2. 2

    Pick indentation

    Choose 2 spaces, 4 spaces or tabs, and tick Sort keys if you want properties in A to Z order.

  3. 3

    Pretty print

    Press Pretty Print JSON. Errors, if any, are shown with their line and column and a suggested fix.

  4. 4

    Copy or save

    Copy the beautified JSON or download it as a .json file.

How to pretty print JSON in code

Every major language can pretty print JSON with its standard library. Use these when you need it in a script, a test or a terminal.

Pretty print JSON in different languages and tools
Language or toolPretty print code
JavaScript / Node.jsJSON.stringify(data, null, 2)
Pythonjson.dumps(data, indent=2)
Python (terminal)python -m json.tool data.json
jqjq . data.json
curl + jqcurl -s https://api.example.com/items | jq .
PHPjson_encode($data, JSON_PRETTY_PRINT)
Gojson.MarshalIndent(data, "", " ")
Java (Jackson)mapper.writerWithDefaultPrettyPrinter().writeValueAsString(data)
C# (System.Text.Json)JsonSerializer.Serialize(data, new JsonSerializerOptions { WriteIndented = true })
PowerShellGet-Content data.json | ConvertFrom-Json | ConvertTo-Json -Depth 10

Pretty print options

2 spaces
The default in most JavaScript tooling and the most compact readable layout.
4 spaces
Matches many Python, Java and C# codebases and makes deep nesting easier to follow.
Tabs
Lets each reader set their own indentation width in their editor.
Sort keys
Orders properties A to Z at every level, like Python's sort_keys=True or jq -S.

Pretty printed vs minified JSON

Comparison of pretty printed and minified JSON
Pretty printedMinified
Best forReading, reviewing, debugging, docsSending over the network, storing
Line breaksOne per property or itemNone
SizeLarger20 to 30% smaller
Same data?YesYes

What formatting can change

Formatting and minifying parse your JSON and write it back out, so the data stays the same but a few representation details can change. Duplicate property names collapse to the last value, integer-like keys such as "10" move ahead of other keys, and numbers beyond 9,007,199,254,740,991 can lose precision. Keep long numeric IDs as strings, and keep your original file when byte-for-byte output matters.

JSON Pretty Print FAQ

Is pretty printing the same as beautifying JSON?

Yes. Pretty print, beautify and prettify all mean adding indentation and line breaks to make JSON readable. None of them change the data.

How do I pretty print JSON in Python?

Use json.dumps(data, indent=2) in code, or run python -m json.tool data.json in a terminal. Add sort_keys=True to order keys alphabetically.

How do I pretty print JSON in JavaScript?

Call JSON.stringify(data, null, 2). The third argument sets the indentation: a number of spaces, or a string such as "\t" for tabs.

How do I pretty print JSON in the terminal?

Pipe it into jq: cat data.json | jq . or curl -s URL | jq . If jq is not installed, python -m json.tool works on any machine with Python.

Can I choose the indentation width?

Yes. Choose 2 spaces, 4 spaces or tabs before pressing Pretty Print JSON. Change it and press the button again to re-indent.

Does pretty printing sort keys?

Not unless you tick Sort keys. Without it, properties keep their original order, except integer-like keys, which JavaScript always places first.

100% private: your data never leaves your browser

No registration, no tracking of your content, no server uploads. Don't just take our word for it:

  • No server, no uploads

    Your files and text are processed entirely on your device. Nothing is ever sent to us.

  • Works offline

    Once loaded, this tool keeps working with your Wi-Fi turned off. Try it.

  • Verify it yourself

    Open your browser's DevTools → Network tab. You'll see zero requests carrying your data.

Explore more tools

More utilities for your next task.

Browse all tools