Code Minifier
Strip comments and whitespace from CSS, JS and HTML safely.
Developer & Security
Pretty-print, validate and minify JSON with precise error positions.
JSON is far stricter than JavaScript object literal syntax, and almost every parse failure comes from one of six causes.
| Error | Cause | Fix |
|---|---|---|
| Unexpected token } | Trailing comma before a closing brace | Remove the last comma — JSON forbids them |
| Unexpected token ' | Single-quoted strings | JSON requires double quotes, always |
| Unexpected token n | Unquoted key name | Every key must be a double-quoted string |
| Unexpected token / | A // or /* */ comment | JSON has no comment syntax. Use JSON5 or strip them |
| Unexpected end of input | Unclosed brace or bracket | Count your delimiters — the tree view shows the imbalance |
| Unexpected token N | NaN or Infinity | Not valid JSON numbers. Use null or a string |
The error message from a native parser tells you the character offset, which is useless in a 4,000-line file. This tool converts that offset into a line and column and scrolls to it, which is the actual information you need.
Into this one, yes. Into most online formatters, no — and the risk is not theoretical.
The JSON people paste into formatters is API response bodies, and API response bodies routinely contain bearer tokens, session identifiers, customer email addresses, internal IDs, and occasionally full payment metadata. A server-side formatter receives all of it, and you have no visibility into what is logged.
There have been repeated incidents of credentials leaking through exactly this path, and it is why many organizations block online formatters at the proxy. Formatting is a pure string transformation — there is no engineering reason for it to happen anywhere but in your own browser. Open the Network tab and paste something; you will see no request.
Only whitespace. Both parse to identical data structures; the difference is entirely in readability versus bytes.
Formatted JSON with two-space indentation is what you want in a config file, a fixture, or anything a human will read or diff. Line-based version control depends on it — a minified JSON file on one line produces a diff that says "line 1 changed" for every edit.
Minified JSON is what you want on the wire. For a typical API response, minification removes 15–30% of the bytes. Over HTTP with gzip or Brotli the saving shrinks considerably, since compression handles repeated whitespace well, but it is still free and worth doing at the API layer.
Structure and scale, immediately. A 12,000-line API response formatted as text is technically readable and practically not.
The tree collapses every object and array to a single line showing its type and child count, so you can see that the response has a data array of 250 items each with 18 fields, and drill into exactly the one you care about.
It also surfaces type information the raw text obscures. It is easy to miss that an ID arrived as the string "1042" rather than the number 1042, and that distinction is the source of a large share of integration bugs. The tree labels every leaf with its type.
No. The JSON specification has no comment syntax. If your file has them it is JSON5 or JSONC, which is common in config files — strip the comments before parsing with a standard parser.
No. JavaScript permits them in object and array literals; JSON does not. This is the single most common cause of parse failures.
Two spaces is the dominant convention and what most formatters, including Prettier, default to. Four spaces and tabs are both valid; consistency matters more than the choice.
Files up to a few hundred megabytes parse successfully, though rendering a formatted view of that size is slow. Use tree view for large payloads — it renders lazily.
Optionally. Sorting produces a canonical form, which makes two JSON documents diffable even when their key order differs. It is off by default because key order is sometimes meaningful to consumers.
Yes. The JSONPath field filters the document — $.data[*].email extracts every email from an array of records.
No. Parsing uses the browser native JSON parser plus a custom position-tracking pass, all in this page.