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?

Strict mode uses the browser's built-in 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.

How big a JSON file can this handle?

Up to about 25 MB before the browser tab starts to lag. The formatter, validator, and minifier all run in a Web Worker so the main thread stays responsive even with large input. For files over ~10 MB, the "Show line numbers" option adds noticeable cost; turn it off for raw speed.

Does the validator catch every kind of error?

Every syntactic error, yes — and it points to the exact line and column. It does not validate against a JSON Schema; for schema validation use a dedicated tool or library like Ajv. It also doesn't check semantic constraints (a "valid JSON object" with a field that should be a number but is a string passes as JSON, fails your schema).

What does "sort keys" do?

Recursively sorts object keys alphabetically. Useful for diffing two JSON documents where the key order differs but the content is the same — sort both, then diff. Note that JSON does not officially specify key order, so sorting is for human-readability only; consumers should never rely on order.

Does the minifier preserve numeric precision?

Yes. The minifier passes through the browser's JSON.parse → JSON.stringify, which preserves number representation as long as the values fit in IEEE 754 doubles. JSON numbers larger than 2^53 (BigInt range) may lose precision — this is a JSON spec limitation, not a tool issue. For BigInt-safe handling use a library like JSON-bigint server-side.

Why might JSON valid here fail to parse in my server?

Most often: encoding (a stray BOM or non-UTF-8 byte the browser silently accepts but a strict server parser rejects), trailing commas in loose mode, or duplicate keys (the JSON spec doesn't forbid them but many parsers behave differently — Python's json module keeps the last, Go's encoding/json keeps the last, Postgres jsonb errors). The "Duplicate keys" check in advanced options flags those.