Format and validate JSON in your browser
This tool pretty-prints, minifies, and validates JSON without sending it anywhere. Paste an API response, a config file, or a log line and get clean, indented JSON back — or a precise error message if it’s malformed. It’s built for developers debugging APIs, anyone tidying config files, and people who handle sensitive payloads they don’t want pasted into a random website.
How it works
The tool runs the browser’s native JSON.parse(input). If parsing succeeds, the
result is re-serialised with JSON.stringify(parsed, null, indent) for
pretty-printing (you choose the indent width, default 2 spaces) or
JSON.stringify(parsed) with no spacing for minifying. Because it parses before
re-printing, any formatted output is guaranteed to be valid JSON. If
JSON.parse throws, the parser’s own error message — often including the
character position — is shown so you can locate the problem.
Example
Paste this messy input:
{"name":"Ada","roles":["admin","editor"],"active":true}
Pretty-printing with a 2-space indent returns:
{
"name": "Ada",
"roles": [
"admin",
"editor"
],
"active": true
}
Minifying the same data collapses it back to one line with no spaces.
Common JSON syntax errors
| Error message | Likely cause |
|---|---|
Unexpected token } in JSON | Trailing comma after the last item |
Unexpected token ' | Single quotes used instead of double quotes |
Expected property name | An unquoted object key |
Unexpected end of JSON input | A missing closing } or ] |
Unexpected non-whitespace character | Extra content after the JSON value |
When to format vs when to minify
Format (pretty-print) when you want to read JSON with your eyes — debugging an API response, reviewing a config file, understanding an unfamiliar data structure, or including a snippet in documentation. The extra whitespace makes the hierarchy visible.
Minify when JSON is going somewhere size matters — embedding in code, sending in an API request, storing in a database field, or passing as a prompt to a language model where every character has a cost. A minified JSON payload is semantically identical to its formatted version; only the whitespace changes.
What the validator catches
A note on what JSON validation means here: JSON.parse implements the full JSON grammar (ECMA-404 / RFC 8259). It catches:
- Missing or mismatched brackets and braces
- Trailing commas (valid in JavaScript but not JSON)
- Single-quoted strings (valid in JavaScript but not JSON)
- Unquoted object keys
- Comments (not part of JSON — use JSONC or another format if you need them)
undefined,NaN,Infinity(JavaScript values with no JSON equivalent)
What it does not catch is type/schema correctness — whether a field named age really contains a number, or whether a required field is present. For that, use a JSON Schema validator.
Everything runs locally in your browser — your JSON is never uploaded.