{}JSON FYI
JSON Formatter

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.

EmptyType: Nodes: 0Depth: 0Size: 0 B

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

2-space indent
Input
{"id":1,"tags":["a","b"]}
Output
{
  "id": 1,
  "tags": ["a", "b"]
}
Tabs
Input
{"a":1,"b":{"c":2}}
Output
{
	"a": 1,
	"b": {
		"c": 2
	}
}
Sorted keys (canonical)
Input
{"name":"Ada","age":36,"id":7}
Output
{
  "age": 36,
  "id": 7,
  "name": "Ada"
}

Sorting keys produces deterministic output — perfect for snapshot tests and clean git diffs.

Use cases

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.

Pretty-print a JSON file

Read input.json, format it with two-space indent, and write the result to output.json.

node format.js
import { readFileSync, writeFileSync } from "node:fs";

const data = JSON.parse(readFileSync("input.json", "utf8"));
writeFileSync("output.json", JSON.stringify(data, null, 2));
Input
{"name":"Ada","age":36,"skills":["math","compilers"]}
Output
{
  "name": "Ada",
  "age": 36,
  "skills": [
    "math",
    "compilers"
  ]
}
Format JSON from stdin (one-liner)

Pipe JSON through a one-liner — handy in shell scripts and CI.

echo '...' | node -e ...
echo '{"a":1,"b":2}' | node -e \
  'process.stdin.on("data", d => console.log(JSON.stringify(JSON.parse(d), null, 2)))'
Output
{
  "a": 1,
  "b": 2
}

Other JSON tools on JSON FYI

Every flow you need — formatter, validator, viewer, pretty print, repair, and the full workbench.

Related tools & guides