W3docs

Tools

JSON Beautifier and Minifier

Pretty-print and validate JSON instantly, or compress it to a single line for transport. Invalid JSON is flagged inline as you type — no API roundtrip, everything runs in your browser.

Valid JSON
Source
Result

About the JSON Beautifier / Validator

JSON Beautifier / Validator takes JSON you paste into the source pane and either pretty-prints it with a configurable indent (0-8 spaces) or collapses it to one minified line. Validity is re-checked on every keystroke: a Valid JSON / Invalid JSON badge in the toolbar updates live, and the Beautify and Minify buttons stay disabled until the input is valid. When it is not, a red banner under the toolbar gives the line and column of the first problem — for example a missing comma or a trailing comma — so you can jump straight to it.

Formatting is lossless. The tool does not parse your JSON into JavaScript values and print them back; it reads the text token by token and only changes the whitespace between tokens. Numbers and strings are copied exactly as you typed them, so 12345678901234567890, 1e400, -0, 1E+2 and long decimals keep every digit, and escapes such as \u00e9 are not rewritten. A JSON.parse/JSON.stringify round trip would silently turn those into 12345678901234567000, null, 0 and 100.

If an object repeats a key, the output keeps both entries and a yellow warning lists the key name and the lines it appears on — most parsers silently keep only the last value, which is rarely what you meant. Setting indent to 0 gives the same output as Minify. Everything runs in your browser; nothing you paste is sent anywhere. Copy puts the result on your clipboard and Clear resets both panes.

Examples

Beautify a minified API responsetext
Input:
{"id":42,"name":"Ada Lovelace","roles":["admin","editor"],"active":true,"meta":null}

Output (indent = 2):
{
  "id": 42,
  "name": "Ada Lovelace",
  "roles": [
    "admin",
    "editor"
  ],
  "active": true,
  "meta": null
}

2 is the tool's default indent value.

Numbers are never rewrittentext
Input:
{"big":12345678901234567890,"huge":1e400,"neg":-0,"exp":1E+2}

Output (Minify):
{"big":12345678901234567890,"huge":1e400,"neg":-0,"exp":1E+2}

Only whitespace changes. Re-serializing through JavaScript numbers would print 12345678901234567000, null, 0 and 100.

Locate a missing commatext
Input:
{
  "id": 1,
  "name": "Ada"
  "role": "admin"
}

Validity badge: Invalid JSON
Error shown: Line 4, column 3: Missing comma before a string (expected "," or "}")

Line and column are 1-based and point at the first token that cannot be parsed.

Frequently asked questions

Why does the tool say my JSON is invalid when it looks fine?

The most common causes are a trailing comma after the last item, single quotes instead of double quotes around strings, unquoted object keys, or a // comment — all valid in a JavaScript object literal but not in JSON. The red banner gives the line and column of the first token that breaks the JSON grammar.

Will Beautify change my numbers or strings?

No. Numbers and strings are copied byte-for-byte from your input; only whitespace between tokens is added or removed. Large integers, 1e400, -0, 1E+2 and unicode escapes come out exactly as you typed them.

What happens if my object has the same key twice?

The tool still formats it and keeps both entries, and shows a warning with the key name and the lines where it repeats. Be aware that JSON.parse and most other parsers keep only the last value for a repeated key.

Does it check that my data has the right structure, or just the syntax?

Just the syntax. {"age": "twelve"} is valid JSON even if your code expects a number. For structural or type checks you need a JSON Schema validator.

Is it safe to paste an API response with real user data or tokens into this tool?

Yes. Parsing and formatting happen in your browser's own JavaScript, and the component never issues a network request with your input. It exists only in that tab's memory and is gone on refresh.

Can this tool fix broken JSON for me automatically?

No. Beautify and Minify stay disabled while the input is invalid, so the tool never guesses at a fix — correct the syntax error at the line and column shown and both buttons re-enable.