Tools
JSON Formatter
Paste JSON and get it pretty-printed, minified or key-sorted live — with errors pinned to the exact line and column. Runs entirely in your browser.
Result
More on this site: all tools ·regex checker ·the arcade
What is this tool?
A free JSON formatter, validator and minifier. Paste any JSON document and it is parsed live with the browser's ownJSON.parse — the same parser your JavaScript code uses — then re-printed the way you ask: indented with 2 spaces, 4 spaces or tabs, or minified to a single line. If the document is invalid, a hand-written validator pinpoints the exact line and column of the first error and explains it in plain English, instead of the cryptic one-liner browsers give you.
Your data never leaves the browser. There is no server: parsing and formatting run client-side, and the only thing stored is your last document and settings, in your own browser's local storage, so it's still there when you come back.
How to use it
- Paste (or type) JSON into the input — it validates and formats as you type.
- Pick an indent style: 2 spaces (the JavaScript ecosystem default), 4 spaces, or tabs.
- Switch to Minify to strip every byte of whitespace before shipping a payload.
- Turn on Sort keys A–Z to order object keys alphabetically at every level — ideal before diffing two documents.
- Hit Copy to grab the result, or load the Sample to try it out.
Common JSON errors, explained
JSON looks like JavaScript but is much stricter. These are the mistakes this validator catches most often — each one is legal in a JS object literal and illegal in JSON:
| Input | Problem |
|---|---|
{"a": 1,} | trailing comma — JSON allows commas only between items |
{'a': 1} | single quotes — strings and keys must use double quotes |
{a: 1} | unquoted key — every property name needs double quotes |
// comment | comments don't exist in JSON (that's JSONC, a different format) |
{"n": NaN} | NaN, Infinity and undefined are not JSON values — use null |
{"b": True} | keywords are lowercase: true, false, null |
{"n": 012} | numbers may not have leading zeros |
"line one | raw newline inside a string — escape it as \n |
{"a":1} {"b":2} | two documents in one input — JSON is exactly one value |
Format or minify?
- Format (pretty-print) for anything a human reads: config files, API responses you're debugging, fixtures, documentation examples. Two-space indent is the de-facto standard in the JavaScript world; tabs let every reader pick their own width.
- Minify for anything a machine reads: payloads on the wire, embedded JSON strings, storage. Whitespace is the only thing removed — minified and formatted JSON are byte-for-byte identical after parsing.
- Sort keys when you need two documents to be comparable: sorted + formatted JSON makes
diffoutput meaningful, deduplicates config snapshots, and keeps version-controlled JSON files from churning when a serializer changes its key order.
Gotchas worth knowing
- Big integers lose precision. JSON itself allows arbitrarily large numbers, but JavaScript parses them as 64-bit floats — anything beyond ±253−1 (9,007,199,254,740,991) gets rounded. A 19-digit ID like
12345678901234567890will come out subtly changed. APIs that use such IDs send them as strings for exactly this reason; this tool has the same behaviour as your JavaScript code, so if a number survives here, it survives in production. - Duplicate keys: last one wins.
{"a":1,"a":2}is technically valid JSON, andJSON.parsekeeps only"a": 2. Formatting such a document silently drops the earlier duplicates. - Key order is not guaranteed by the spec.JavaScript preserves insertion order for string keys in practice, but no consumer should rely on it — if order matters to a diff or a hash, sort the keys.
-0,1e2and friends are normalised. Re-printing goes through JavaScript's number formatting, so1.0becomes1and1e2becomes100— same value, canonical spelling.
FAQ
Is it free? Yes — free, no sign-up, no limits.
Is my JSON uploaded anywhere? No. Parsing happens in your browser; the page works the same if you go offline after loading it. That makes it safe for API responses, tokens and other data you'd rather not paste into a random website.
How large a document can it handle? Parsing is linear-time, so multi-megabyte documents format in milliseconds. The practical limit is your browser's memory, not this tool.
Which JSON spec is this? RFC 8259 / ECMA-404, as implemented by JSON.parse — the strict interchange format. Comments, trailing commas and unquoted keys belong to supersets like JSONC and JSON5, which this tool intentionally rejects (with a hint telling you so).
Built from scratch for this site in vanilla TypeScript — a pure, unit-tested formatting core with a hand-written validator for exact error positions, and zero runtime dependencies.