JSON Formatter & Validator

Beautify, minify and validate JSON — with sorted keys, custom indentation and precise error locations.

🔒 Runs entirely in your browser — nothing you type is uploaded or stored on a server.

The JSON Formatter takes raw JSON — a minified API response, a config file, a log entry — and makes it readable. Paste your JSON and it is validated and re-formatted live with the indentation you choose (2 spaces, 4 spaces or tabs). One click minifies it back down for production, and an optional switch sorts every object's keys alphabetically, at every nesting level.

The validator is the half you'll thank yourself for. When JSON is broken, the tool doesn't just say “invalid” — it points at the exact line and column of the first error, which turns hunting for a missing comma in a 500-line config into a two-second fix. It applies the same strict rules as browsers and APIs: double quotes only, no trailing commas, no comments — so if it passes here, it will parse in production.

Sorted keys plus consistent indentation has a second superpower: diff-friendly JSON. Format two API responses the same way, sort the keys, and paste them into the Text Compare tool — only real differences light up, not noise from key order. And because everything runs in your browser, pasting responses full of tokens, keys or personal data is safe; nothing is uploaded.

How to use

  1. Paste your JSON — it is validated and formatted instantly as you type.
  2. Pick the indentation you want: 2 spaces, 4 spaces or tabs.
  3. Click “Minify” to strip all whitespace for production, or “Format” to switch back.
  4. Tick “Sort keys A → Z” for a canonical, diff-friendly ordering.
  5. If the JSON is invalid, read the status line — it names the exact line and column of the first error.
  6. Copy the result or download it as a .json file.

Examples

Reading an API response
A one-line, 40 KB minified response becomes neatly indented and readable — the structure of nested objects and arrays is suddenly obvious.
Finding a config typo
A broken deploy config shows “✗ Invalid JSON at line 14, column 3” — the trailing comma is fixed before your coffee cools.
Diffing two payloads
Format both payloads with sorted keys and 2-space indent, then compare them — only genuinely changed values show up as differences.
Shrinking a fixture
Minify removes every unnecessary space and line break — a formatted 120 KB test fixture drops to 80 KB without changing its meaning.

Frequently asked questions

Why is my JSON invalid when it looks fine?
The usual culprits are single quotes instead of double quotes, a trailing comma after the last item, unquoted keys, or comments. Those are legal in JavaScript but not in strict JSON — and this validator applies the same strict rules browsers and APIs use.
What exactly does Minify do?
It removes all indentation and line breaks, producing the smallest equivalent JSON. The data itself is untouched — minified and formatted versions parse to exactly the same result.
Is sorting keys safe?
Yes. The JSON specification treats object keys as unordered, so any standards-compliant consumer reads sorted output identically. Sorting applies to objects at every depth; the order of arrays — which is meaningful — is never changed.
Can it change my numbers?
One honest caveat: JSON is parsed with JavaScript numbers, so integers beyond 15–16 digits (like some 64-bit IDs) can lose precision when re-printed. If your data contains such IDs as bare numbers, keep them as strings.
How large a file can it handle?
Multi-megabyte JSON formats fine in a modern browser — the work is a single native parse and stringify. Extremely large files are limited only by your device's memory.
Is my JSON uploaded?
No. Validation and formatting run entirely in your browser, so API responses containing tokens, keys or personal data never leave your machine.