JSON Pretty Print — Free Online Beautifier
Paste JSON and get a pretty-printed, indented version instantly. Matches JSON.stringify(obj, null, 2) in JavaScript and json.dumps(indent=2) in Python.
Ready when you are.
Paste JSON on the left, or click Sample to try a quick example. Validation runs as you type — entirely in your browser.
What does "pretty print" mean?
Pretty printing is the universal term for taking a compact JSON document — usually one long line — and adding indentation, line breaks, and consistent spacing so a human can read it. The data is unchanged; only whitespace is added.
Almost every language ships with a pretty-printer built in:
- JavaScript:
JSON.stringify(obj, null, 2) - Python:
json.dumps(obj, indent=2) - Ruby:
JSON.pretty_generate(obj) - Go:
json.MarshalIndent(obj, "", " ") - Command line:
jq .orpython3 -m json.tool
This tool gives you the same result without writing any code — paste, click, copy.
Examples
{"id":1,"name":"Ada"}{
"id": 1,
"name": "Ada"
}Equivalent to JSON.stringify(obj, null, 2).
{"items":[1,2,3],"total":6}{
"items": [
1,
2,
3
],
"total": 6
}Equivalent to json.dumps(obj, indent=4).
{"z":1,"a":2,"m":3}{
"a": 2,
"m": 3,
"z": 1
}Equivalent to json.dumps(obj, indent=2, sort_keys=True).
{"name":"Ada","tags":["a","b"]}{
"name": "Ada",
"tags": ["a", "b"]
}{"a":{"b":{"c":{"d":"deep"}}}}{
"a": {
"b": {
"c": {
"d": "deep"
}
}
}
}Use cases
- Quick code-free pretty print
When you don't want to open a REPL just to format one payload.
- Matching your codebase style
Pick the same indent your project uses so the output drops in cleanly.
- Teaching JSON to beginners
Pretty-printed JSON is dramatically easier to read than the wire format.
- Comparing two payloads
Pretty-print both, then diff them — meaningful changes pop out.
Frequently asked questions
What is JSON pretty print?+
Pretty print is the term for formatting JSON with indentation and line breaks so a human can read it. It's what JSON.stringify(obj, null, 2) does in JavaScript and json.dumps(obj, indent=2) in Python.
How do I pretty print JSON in JavaScript?+
JSON.stringify(value, null, 2) returns a pretty-printed string with 2-space indent. Replace 2 with 4 for 4-space indent, or '\t' for tabs.
How do I pretty print JSON in Python?+
import json; print(json.dumps(data, indent=2)) prints it pretty. Add sort_keys=True to canonicalize.
How do I pretty print JSON from the command line?+
Use jq: cat file.json | jq . pretty-prints any JSON to stdout. Or python3 -m json.tool file.json works without installing anything.
Is online pretty printing safe?+
On JSON FYI, yes — your JSON is never sent to a server. Everything runs in your browser. Many other online tools do upload, so check before pasting sensitive data.
Pretty-print JSON in code
Stable, sorted-key output for diffs, fixtures, and snapshot tests.
Stable, diff-friendly JSON for fixtures and snapshots — keys sorted alphabetically.
import { readFileSync, writeFileSync } from "node:fs";
const sortKeys = (v) =>
Array.isArray(v)
? v.map(sortKeys)
: v && typeof v === "object"
? Object.fromEntries(Object.keys(v).sort().map(k => [k, sortKeys(v[k])]))
: v;
const data = JSON.parse(readFileSync("input.json", "utf8"));
writeFileSync("output.json", JSON.stringify(sortKeys(data), null, 2));{"name":"Ada","age":36,"id":1}{
"age": 36,
"id": 1,
"name": "Ada"
}Other JSON tools on JSON FYI
Every flow you need — formatter, validator, viewer, pretty print, repair, and the full workbench.
Pretty-print with custom indent and sort keys.
Strict RFC 8259 syntax check with line + column.
Browse JSON as an interactive collapsible tree.
Compare two JSON files structurally with paths.
Convert arrays into spreadsheet-ready CSV.
Well-formed XML with attributes and indenting.
Idiomatic YAML 1.2 for Kubernetes & Compose.
Free in-browser formatter — nothing uploaded.
Pinpoint errors with a catalog of common fixes.
Validate data against a JSON Schema — powered by Ajv.
All tools in one editor: validate, format, view, query.