Z

JSON Formatter & Validator

Pretty-print, minify and validate JSON with clear error messages — entirely in your browser.

Runs in your browser — files never leave your device

Output

How it works

Paste any JSON and choose one of three actions: Format (2 spaces) — the most common web convention — Format (4 spaces) for deeper visual nesting, or Minify to collapse everything onto a single line. The input is validated first, and the result appears beside it with a copy button.

Under the hood the tool uses your browser’s native, strict JSON parser — the same engine production JavaScript relies on — and, when the input is valid, re-serializes it at the indentation you chose. If parsing fails, you see the parser’s own error message, which names the unexpected token and its character position so you can jump straight to the problem.

A concrete example: pasting the single 39-character line {"name":"Ada","skills":["math","code"]} and clicking Format (2 spaces) produces a seven-line document with each key and array item on its own line — 61 characters in all. Minify performs the exact inverse, collapsing those seven lines back to the 39-character original.

This is the fastest way to make sense of a minified API response, a webhook payload, or a JSON blob buried in a log line — and to validate hand-edited files like package.json before they break a build. Minify is useful in the other direction: shrinking JSON before embedding it in an environment variable, a query string, or a config value.

One thing to understand: the output is your document parsed and re-serialized, not merely re-indented. That normalizes a few things — duplicate keys collapse to the last value, escape sequences like \u00e9 become the literal character (é), and number spellings are canonicalized (1e3 becomes 1000). It also means strict JSON rules apply exactly as they will in production: single quotes, trailing commas, comments, and unquoted keys are all rejected.

Frequently asked questions

Why is JSON with single quotes invalid?
The JSON specification only allows double quotes around keys and string values. JavaScript object literals accept single quotes and unquoted keys, which is why code pasted out of a JS file often fails here — replace the quotes and validate again.
Are trailing commas or comments allowed?
No. Strict JSON forbids trailing commas, comments, and NaN or Infinity as numbers, and this tool applies exactly the same rules as JSON.parse in production — so anything that validates here will parse anywhere. If you maintain JSONC or JSON5 files (VS Code settings, for example), strip the comments before validating.
How do I read the error message?
It comes straight from your browser’s JSON parser and usually names the unexpected token plus the character position of the first problem; the exact wording differs between Chrome, Firefox, and Safari. Look just before that offset — the usual culprits are a missing comma between entries, an unescaped double quote inside a string, or an extra closing bracket.
Does formatting change my data?
Structure and values are preserved, but the document is parsed and re-serialized, which normalizes a few spellings: duplicate keys collapse to the last occurrence, Unicode escapes become literal characters, and 1e3 is rewritten as 1000. If byte-for-byte fidelity matters — a signed payload, for example — keep the original alongside the formatted copy.
Why did my long numeric ID lose digits?
JavaScript stores numbers as 64-bit floats, so integers beyond 9007199254740991 (2^53 − 1) cannot be represented exactly — 12345678901234567890 comes back as 12345678901234567000. This is a property of every JavaScript-based formatter, not corruption in your file. APIs avoid it by transmitting large IDs as strings.
What does Minify actually remove?
Only inter-token whitespace: indentation, line breaks, and the spaces after colons and commas. The seven-line example in the how-it-works section shrinks from 61 formatted characters back to 39. Minified and pretty output parse to exactly the same data.
Is my JSON uploaded?
No. Parsing and formatting run entirely in your browser using its built-in JSON engine — the text never leaves your device, and nothing is stored after you close the tab.