Beautify & pretty-print JSON
Paste minified or messy JSON and get clean, readable output. Choose 2/4 spaces or tabs, sort keys for stable diffs, and copy the result with one click.
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.
Why pretty-print JSON?
Minified JSON is great for transport but painful to read. A formatter reinserts indentation and newlines so you can scan structure, spot missing fields, and review diffs in version control.
JSON FYI's formatter never alters the underlying data — only whitespace changes. Use the Sort keys option to canonicalize objects so unrelated key reordering doesn't pollute git diffs or test snapshots.
Examples
{"id":1,"tags":["a","b"]}{
"id": 1,
"tags": ["a", "b"]
}{"a":1,"b":{"c":2}}{
"a": 1,
"b": {
"c": 2
}
}{"name":"Ada","age":36,"id":7}{
"age": 36,
"id": 7,
"name": "Ada"
}Sorting keys produces deterministic output — perfect for snapshot tests and clean git diffs.
Use cases
- Code review
Format JSON fixtures before committing so reviewers see meaningful diffs, not whitespace churn.
- Reading log payloads
Pipe a single-line log entry through the formatter to see the structure in seconds.
- Building documentation
Pretty-print API examples for your docs site. Consistent indent across every example.
- Snapshot testing
Sort keys before snapshotting so test output doesn't flip when serializers reorder fields.
- Sharing in chat
Paste a formatted JSON block into Slack or GitHub instead of one unreadable line.
Frequently asked questions
What does formatting JSON do?+
Formatting (also called beautifying or pretty-printing) adds consistent indentation and line breaks so JSON becomes readable. The data is unchanged.
Should I use 2 or 4 spaces?+
2 spaces is the most common style in modern config files and APIs. 4 spaces or tabs are also valid — pick what your team uses.
Does sorting keys change the JSON?+
Object key order is not significant in JSON, so sorting keys is purely cosmetic. It helps with diffs and snapshot tests.
Is the formatted JSON safe to commit?+
Yes. Formatting only adds whitespace; the parsed value is identical. Many teams commit pretty-printed JSON for clean diffs.
Format JSON in code
JavaScript, Python, Go, and Ruby snippets — copy and paste into your project.
Read input.json, format it with two-space indent, and write the result to output.json.
import { readFileSync, writeFileSync } from "node:fs";
const data = JSON.parse(readFileSync("input.json", "utf8"));
writeFileSync("output.json", JSON.stringify(data, null, 2));{"name":"Ada","age":36,"skills":["math","compilers"]}{
"name": "Ada",
"age": 36,
"skills": [
"math",
"compilers"
]
}Pipe JSON through a one-liner — handy in shell scripts and CI.
echo '{"a":1,"b":2}' | node -e \
'process.stdin.on("data", d => console.log(JSON.stringify(JSON.parse(d), null, 2)))'{
"a": 1,
"b": 2
}Other JSON tools on JSON FYI
Every flow you need — formatter, validator, viewer, pretty print, repair, and the full workbench.
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.
Beautify JSON with JS- or Python-style indent.
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.