JSON pretty print
input.json
Paste your JSON here
or drop a .json file anywhere here
Formatted output appears here.
The equivalent in every language you might reach for
Pretty printing is the operation you have written a one-liner for in every language. For reference, and because the flags are easy to forget:
# jq — 2-space indent by default, -S also sorts keys
jq . data.json
jq -S . data.json
# Python
python -m json.tool --indent 2 data.json
python -c "import json,sys; print(json.dumps(json.load(sys.stdin), indent=2, sort_keys=True))"
# Node
node -e "console.log(JSON.stringify(require('./data.json'), null, 2))"
# Go
json.Indent(&out, in, "", " ") // or json.MarshalIndent(v, "", " ")
# Ruby
ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
# PowerShell
Get-Content data.json | ConvertFrom-Json | ConvertTo-Json -Depth 100
# curl, straight into a pretty printer
curl -s https://api.example.com/v2/orders | jq .All of them produce the same shape of output. The differences worth knowing:ConvertTo-Json defaults to a depth of 2 and silently truncates deeper structures unless you pass -Depth; Go’s MarshalIndent escapes <,>, and & inside strings as the escape sequences\u003c, \u003e, and \u0026unless you call SetEscapeHTML(false) on the encoder; and Python sorts keys only when you ask.
When the browser is the better tool
The command line wins for files and pipelines. This page wins when:
- The JSON is on your clipboard, not on disk, and you do not want a temporary file just to read it.
- The document is long enough that reading indented text is the wrong interface, and you would rather click through a tree.
- It does not parse yet, and you want the line, the column, and a caret rather than
parse error: Expected separator between values at line 1, column 20. - The payload contains credentials or customer data you would rather not paste into a web service that posts it to a backend. Nothing here is uploaded.
Indentation and diffs
Pretty printing exists to make JSON reviewable, and the indent width you choose has a direct effect on that. Two spaces keeps deeply nested documents inside a reasonable line length, which matters because JSON nests fast — five levels at four spaces starts every line twenty columns in.
If you pretty print JSON that is checked into version control, pick one width and one key order and stay with them. Re-printing the same data with different settings produces a diff that touches every line and communicates nothing. Sort keys is the reliable way to make two documents comparable when they came from sources that emit properties in different orders.
Common questions
What is the browser equivalent of json.dumps(indent=2)?
JSON.stringify(value, null, 2). Python adds a space after the separator by default, so json.dumps(d, indent=2) and JSON.stringify(v, null, 2) produce byte-identical output for the same data — Python only differs when you pass custom separators.
How do I pretty print and sort keys at the same time?
Press Sort keys, which sorts A→Z at every nesting level and re-prints. That is the equivalent of json.dumps(d, indent=2, sort_keys=True) or jq -S ..
Does pretty printing preserve the original key order?
Yes, unless you sort. Property order is preserved exactly as the parser read it, which for JavaScript means insertion order for all non-integer-like keys. Keys that look like array indices are ordered numerically first — a property of JavaScript objects, not of this tool.
Can I pretty print into a fixed line width?
No, and no standard tool does. JSON pretty printing indents by depth rather than wrapping at a column, so a single long string stays on one line. If you need wrapped output, the format you want is YAML.
The rest of the toolkit
Same engine, same privacy — every page runs entirely in your browser.
JSON formatter
Indent JSON with 2 spaces, 4 spaces, or tabs, then copy or download the result.
JSON viewer
Expand, collapse, and search a JSON tree; copy any value or its path.
JSON validator
Find syntax errors with exact line, column, and a suggested fix.
JSON minifier
Strip whitespace and see the byte savings before and after.
JSON beautifier
Turn minified or broken JSON into clean, highlighted output.
JSON to CSV
Flatten an array of objects into spreadsheet rows, quoted correctly.
CSV to JSON
Parse CSV — quotes, embedded commas, any delimiter — into JSON records.
JSON to YAML
Config-ready YAML with no folded strings and no anchors.
YAML to JSON
YAML 1.2 parsing, multi-document streams, errors reported by line.
JSON to XML
Arrays repeat their tag; @keys become attributes.
XML to JSON
Entities, CDATA, and namespaces handled by the browser’s XML parser.
JSON diff
Compare two documents by path — key order and indentation are ignored.