JSON Formatter, Validator & Minifier
Format messy JSON into readable indented output, validate it with line/column error messages, or minify it for transport. Strict-mode parsing for spec-compliant JSON; loose mode handles trailing commas, comments, and unquoted keys (JSON5). Everything runs in your browser — paste production data without it ever leaving your tab.
How to use the JSON Formatter
Paste JSON, pick your indent size, and click Format. The output panel shows the prettified version. If the input fails to parse, the info bar above the output panel reports the exact line and column of the syntax error, along with the parser's message. Click Minify to get the same data with all unnecessary whitespace removed — useful for copying into a network request or shrinking a payload before transport.
Switch the parser to Loose (JSON5) when you're pasting JavaScript object literals, config files with comments, or LLM output that includes trailing commas. The loose parser accepts all of those, then emits standard JSON in the output panel — so you can round-trip non-strict input into strict output.
Sort keys recursively alphabetizes every object's keys. The most useful application is comparing two JSON documents where the key order differs: sort both, then diff with the JSON Diff tool. Flag duplicate keys catches the sneakiest JSON bug — most parsers silently keep one of the duplicates, but which one depends on the parser. Production bugs hide here.
What is JSON, briefly
JSON (JavaScript Object Notation) is a text-based data format defined in RFC 8259 / ECMA-404. It encodes structured data using six types: objects, arrays, strings, numbers, booleans, and null. The spec is short — about 15 pages — and that minimalism is why JSON has become the de-facto data interchange format for the web.
The strict JSON spec forbids: trailing commas, comments, unquoted keys, single-quoted strings, and leading or trailing decimal points on numbers. JSON5 — a superset commonly used in tooling and config files — relaxes all of those. The two parsers in this tool let you work with either.
What the formatter actually does
On click, the input is passed to a Web Worker that runs the chosen parser. The parser returns a
JavaScript object tree, which is re-serialized with JSON.stringify using the indent
you selected. The "sort keys" option runs a depth-first key-sort over the object tree before
re-serializing. The "duplicate keys" check runs a streaming variant of the parser that keeps a per-object
key set and reports any collisions with their positions.
Performance: for JSON under 1 MB the round-trip is instant. For files up to 25 MB it stays under 500ms. Above that you'll see the worker thread take a few seconds; the main thread (and your scrolling) stays responsive throughout because the work is off-thread.
Common use cases
- Debugging an API response. Paste the response body from your DevTools, format, and read it without the eye strain of a one-line JSON blob.
- Cleaning LLM output. Models that produce JSON sometimes wrap it in markdown code fences or add trailing commas. Loose mode handles both; the output gives you strict JSON ready to feed downstream.
- Comparing two API responses. Sort keys on both, then paste into JSON Diff to see structural differences without false positives from key order.
- Reviewing JWT payload contents. The JWT decoder shows claims in a table; the formatter shows them in raw indented JSON for easier copying.
- Preparing JSON for embedding in code. Minify to remove whitespace, copy, paste into a string literal. The reverse (taking a string-escaped JSON blob and unescaping it) is on the roadmap.
- Schema reverse-engineering. Paste a sample response into the JSON to TypeScript tool to generate interface definitions matching the structure.
Frequently asked questions
What's the difference between strict and loose parsing?
JSON.parse — rejects trailing commas, single-quoted keys, comments, and unquoted keys. Loose mode (powered by JSON5) accepts all of those plus hex literals, leading-decimal numbers, and multi-line strings. Use strict for production data; use loose when copying snippets from JavaScript source or config files.