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.
Also on Txtset: convert tabular data to and from JSON · fix Python indentation and tabs · convert a YAML file into JSON · lay out a SQL query the same way.
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
- Paste your JSON — it is validated and formatted instantly as you type.
- Pick the indentation you want: 2 spaces, 4 spaces or tabs.
- Click “Minify” to strip all whitespace for production, or “Format” to switch back.
- Tick “Sort keys A → Z” for a canonical, diff-friendly ordering.
- If the JSON is invalid, read the status line — it names the exact line and column of the first error.
- Copy the result or download it as a .json file.
Examples
A one-line, 40 KB minified response becomes neatly indented and readable — the structure of nested objects and arrays is suddenly obvious.
A broken deploy config shows “✗ Invalid JSON at line 14, column 3” — the trailing comma is fixed before your coffee cools.
Format both payloads with sorted keys and 2-space indent, then compare them — only genuinely changed values show up as differences.
Minify removes every unnecessary space and line break — a formatted 120 KB test fixture drops to 80 KB without changing its meaning.