Turn a single unreadable line of JSON into properly indented, syntax-highlighted text — with your choice of 2 spaces, 4 spaces or tabs. The formatter validates as it goes, so a broken payload tells you which line to fix instead of failing silently. Everything happens in your browser; nothing is uploaded.
A JSON formatter re-inserts the line breaks and indentation that a minified payload leaves out. The data is untouched — only the whitespace between tokens changes — so the formatted output parses to exactly the same object. What you gain is the ability to see the shape: which keys sit at the top level, how deep the nesting goes, where an array of objects begins.
{"order":9001,"customer":{"id":7,"name":"Ada Lovelace"},"items":[{"sku":"A1","qty":2}],"paid":true,"note":null}
{
"order": 9001,
"customer": {
"id": 7,
"name": "Ada Lovelace"
},
"items": [
{
"sku": "A1",
"qty": 2
}
],
"paid": true,
"note": null
}
Because formatting requires parsing, a formatter doubles as a validator. If the text cannot be parsed it cannot be indented — which is why this tool reports the failing line and column rather than returning an empty box.
.json file onto the page..json file.There is no standard — RFC 8259 says nothing about whitespace — but the ecosystem has strong conventions, and matching them keeps your diffs quiet.
| Style | Used by | Best for |
|---|---|---|
| 2 spaces | npm (package.json), Prettier, ESLint, most JS tooling |
The safe default. Deep nesting stays on screen. |
| 4 spaces | Python's json.tool, many .NET and Java toolchains |
Shallow config files where clarity beats width. |
| Tab | Go's json.MarshalIndent examples, some editors |
Letting each reader pick their own visual width; smallest file size. |
If the file is checked into a repository, the correct answer is simply "whatever the
repository already uses". Reformatting a committed package.json from 2 to
4 spaces produces a diff that touches every line and hides the one change that mattered.
A browser tool is fastest for a payload you just copied out of a network tab. For files you already have locally, these are the usual equivalents.
# Python — built in, everywhere
python3 -m json.tool --indent 2 in.json out.json
# jq — the standard JSON CLI
jq '.' in.json > out.json
jq --tab '.' in.json # tab indentation
# Node.js — no dependencies
node -e 'console.log(JSON.stringify(require("./in.json"), null, 2))'
// JavaScript / TypeScript
JSON.stringify(value, null, 2);
# Python
json.dumps(value, indent=2, ensure_ascii=False)
// Go
b, _ := json.MarshalIndent(value, "", " ")
Open the file, make sure the language mode is JSON, then press
ShiftAltF
(ShiftOptionF on
macOS). The indent width comes from editor.tabSize.
Each of these needs the file on disk and a working toolchain. When you have neither — a payload pasted from a chat message, a colleague's laptop, a locked-down machine — the browser formatter is the one that always works.
JSON objects are unordered by definition, so two files can hold identical data and still produce a hundred-line diff purely because the keys were serialised in a different order. Enabling Sort keys before formatting normalises both sides alphabetically, and the diff collapses to the lines that genuinely changed.
This is worth doing before committing generated files — lock files, exported settings, API snapshots used as test fixtures. It is worth not doing when key order carries meaning for a human reader, as with an ordered list of pipeline stages expressed as an object.
A JSON formatter re-inserts the line breaks and indentation that a minified payload leaves out. The data is untouched — only the whitespace between tokens changes — so the formatted output parses to exactly the same object.
Two spaces is the de facto default: it is what npm writes into package.json, what most linters expect, and it keeps deeply nested documents from running off the screen. Four spaces suits shallow config files, and tabs are useful when readers need to control the visual width themselves.
No. Formatting only adds whitespace. The one thing to be aware of is that JSON objects are unordered by definition, so if you enable Sort keys the key order in the text will change even though the data is still equivalent.
No formatter can indent text it cannot parse. When the input is malformed the validator reports the reason and the exact line and column so you can repair it first — the most common causes are trailing commas, single quotes and comments.
Yes. This formatter runs entirely as JavaScript in your browser and makes no network request with your content, so tokens, customer data and internal API responses never leave your machine.