JSON Formatter, Validator & Minifier
Paste any JSON, get a pretty-printed or minified version. Validates strict JSON and reports the precise location of any syntax error. Everything runs in your browser.
About this tool
JSON (JavaScript Object Notation) is the most widely-used data interchange format in modern APIs and configuration files. Its grammar is small but strict: keys must be double-quoted strings, trailing commas are forbidden, and only a fixed set of value types is allowed. A single missing comma or mismatched bracket invalidates the entire document.
This formatter parses your input with the browser's native JSON.parse() and re-emits it with the indentation of your choice (or as a single line when minified). Because all parsing is local, there is no network round-trip and no opportunity for your data — credentials, tokens, anything — to leave your machine.
How it works
The formatter performs three steps on every run:
- Parse. The input is fed to
JSON.parse(). If parsing fails, the error and approximate position are reported in the status line. - Re-serialize. The resulting JavaScript value is passed back to
JSON.stringify(). In format mode, an indentation argument controls spacing; in minify mode, no indentation is used. - Measure. The output size in bytes is reported so you can quickly see how much whitespace your config or payload contains.
Common use cases
- Debugging API responses. Drop a raw payload from
curlor DevTools to make it readable. - Validating config files. Catch a stray comma before deploying a JSON configuration to production.
- Shrinking payloads. Use minify mode to remove formatting whitespace from a static JSON asset.
- Normalising stored JSON. Format strings stored in databases or log files into something a human can scan.
JSON vs JSON5 vs JSONC. Strict JSON disallows comments and trailing commas. JSON5 and JSONC (JSON with Comments, used by VS Code and TypeScript configs) relax those rules. This tool implements strict JSON per RFC 8259; if you see "Unexpected token", check for comments or trailing commas in your source.
Frequently asked questions
Does my JSON get uploaded anywhere?
No. All parsing and formatting runs inside your browser tab using the built-in JSON API. There is no server-side component to this tool and no network request is made with your input.
Why does my JSON show "Unexpected token"?
The most common causes are trailing commas after the last element of an array or object, single-quoted strings (JSON requires double quotes), unquoted object keys, and // or /* */ style comments. Strict JSON allows none of these.
What is the maximum JSON size I can format?
Practical limits are determined by your browser's memory. Documents up to several megabytes format almost instantly in any modern browser. Extremely large documents (tens of megabytes) may briefly freeze the UI because JSON.parse runs synchronously.
What indentation should I use?
Two spaces is the most common convention in modern projects and matches the defaults of Prettier, ESLint, and the Node ecosystem. Four spaces is more common in Python projects. Use what matches your codebase.
How is this different from a JSON linter?
A linter applies style rules (key ordering, formatting consistency, schema validation) on top of basic syntax checking. This tool validates against the grammar in RFC 8259 — that is, it answers "is this valid JSON?" — and re-emits the document in a chosen shape. For schema-based validation, see JSON Schema.
Tips
- If a payload contains escaped JSON inside a string (a common pattern for log lines), format the outer document first, then copy the inner string and run it through the formatter again.
- Use Tab to indent inside the textarea on most browsers (browsers vary; some require Ctrl+Tab to escape focus).
- Minified JSON is byte-for-byte deterministic given the same input — useful for hashing or signing payloads.