What This Tool Does
This formatter takes any JSON text, parses it, and re-serializes it with consistent 2-space indentation using JavaScript's native JSON.stringify(parsed, null, 2). That means every object and array gets properly nested, line-broken, and spaced — turning a dense wall of text into something you can actually read and scan.
Because the input has to be parsed before it can be reformatted, this tool doubles as a JSON validator. If your JSON has a syntax error, parsing fails and you get a clear error message instead of silently mangled output — so you know immediately that something is wrong and roughly where to look.
How to Use It
- Paste your JSON — minified, hand-typed, or copied from an API response — into the Input box.
- Click Run.
- If the JSON is valid, the cleanly indented, pretty-printed version appears in the Output box.
- If the JSON is invalid, an error message appears below the boxes describing what failed to parse.
- Copy the formatted result from the Output box, or click Clear to start over.
Worked Example
Input (minified):
{"id":101,"name":"Widget","tags":["a","b"],"active":true,"meta":{"price":9.99,"inStock":null}}
Output (formatted):
{
"id": 101,
"name": "Widget",
"tags": [
"a",
"b"
],
"active": true,
"meta": {
"price": 9.99,
"inStock": null
}
}
Common Use Cases
- Debugging API responses — paste a raw, single-line response body to instantly see its structure and spot the field you're looking for.
- Cleaning up minified config files — reformat compacted
.jsonconfig so it's editable and diff-friendly in version control. - Code review — present JSON payloads in a readable layout so reviewers can actually follow the nesting instead of scrolling one giant line.
- Documentation — generate clean, consistently indented examples to paste into READMEs, API docs, or tickets.
- Quick sanity checks — confirm a payload is valid JSON before feeding it into a script, test fixture, or another tool.
Common JSON Mistakes This Catches
Because formatting relies on JSON.parse, any text that isn't strictly valid JSON will fail with a descriptive error rather than producing garbled output. Mistakes this surfaces include:
- Trailing commas — e.g.
{"a": 1, "b": 2,}. Valid in JavaScript object literals, but not in JSON. - Single quotes instead of double quotes — e.g.
{'a': 1}. JSON strings and keys must use double quotes. - Unquoted keys — e.g.
{a: 1}. All JSON object keys must be quoted strings. - Missing commas between properties — e.g.
{"a": 1 "b": 2}. Every property needs a separating comma. - Comments in the file — standard JSON has no comment syntax, so
// noteor/* note */will cause a parse failure. - Unbalanced brackets or braces — a missing closing
}or]will produce an "unexpected end of input" style error.
FAQ
Does this validate JSON Schema, or just JSON syntax?
Just syntax and well-formedness. It confirms your text is valid, parseable JSON — it does not check field types, required properties, or enum values against a JSON Schema.
Can I use this to minify instead?
No, this tool only pretty-prints with 2-space indentation. For compact, whitespace-free output, use the Minify JSON tool instead.
Is my data uploaded anywhere?
No. Formatting happens entirely in your browser with JavaScript's built-in JSON parser — nothing is sent to a server or stored.
Why does it say my JSON is invalid when it looks fine?
JSON is stricter than JavaScript object literals. Trailing commas, single quotes, unquoted keys, and missing commas are the usual culprits — see the list above.
Does it support JSON5 or JSONC (comments)?
No. This tool follows the strict JSON specification, so comments and other JSON5/JSONC-only syntax will be rejected.