JSON Formatter
Format, validate, and minify JSON data with syntax highlighting.
About JSON formatting
JSON — JavaScript Object Notation — is the de facto data format of the web. Almost every API you'll touch returns JSON, almost every config file in the modern stack uses JSON or one of its close cousins (JSON5, JSONC, NDJSON), and almost every log aggregator stores events as JSON. The format itself is simple, but the moment you have to read a 200-line API response that came back as one long string, or a config file that someone hand-edited and broke, you need a formatter.
This tool does three things: it pretty-prints valid JSON with proper indentation, it minifies it back down to a single line for transport, and it validates it — telling you exactly where a syntax error sits. Everything runs in your browser. The JSON you paste never leaves your machine, which matters when you're debugging API responses that contain customer data or auth tokens.
Pretty-printing vs. minifying
Pretty-printing inserts newlines and indentation so structure is readable. Use it for debugging, for committing JSON to source control where diffs matter, and for documentation. Minifying strips all whitespace down to the minimum legal output. Use it for HTTP request bodies, for embedding JSON in attributes or query strings, and anywhere bytes-on-the-wire matter. The two operations are perfectly reversible — the parsed structure is the same either way.
Common reasons JSON breaks
- Trailing commas. JavaScript allows them in arrays and objects; strict JSON does not.
[1, 2, 3,]is invalid. - Single quotes. JSON requires double quotes around strings and keys.
{'a': 1}won't parse. - Unquoted keys.
{a: 1}is JavaScript object literal syntax, not JSON. - Comments. Standard JSON doesn't allow
//or/* */. If you see comments, you're looking at JSONC or JSON5. - Unescaped control characters in strings. Tabs and newlines inside a string need to be
\tand\n. - Trailing data. A JSON document is a single value. Two objects in a row aren't valid — that's NDJSON, which is one JSON value per line.
- BOM or invisible characters. A byte-order mark at the start of a file will cause some parsers to fail. Copy-pasting from Word or some chat clients can sneak in non-breaking spaces that look identical to regular spaces but aren't.
How errors are reported
When parsing fails, the tool surfaces the underlying error from the browser's parser, which usually pinpoints the line and column where it gave up. The actual problem is sometimes a few characters earlier — a missing closing brace, for instance, isn't detected until the parser hits something unexpected later on. If the message says "Unexpected token ]" and the bracket itself looks fine, look upward for the missing comma or extra one.
Useful tricks
- Sorting keys. If you're diffing two JSON files that came from different sources, sorting the keys alphabetically before comparing eliminates noise from key ordering.
- Stringified JSON inside JSON. APIs sometimes return a JSON string whose value is itself stringified JSON — you'll see
"\""-laden values. Decode it once, paste the inner string back in, decode again. - Detecting NDJSON. If pasting fails but each individual line parses, you have NDJSON (newline-delimited JSON), common in log streams and Kafka topics.