Empty input
How it works
JSON Formatter formats, minifies and validates JSON. If your JSON is invalid, it shows the exact location of the error as line:column. The tree view helps you find your way through large API responses and config files.
Quick start
- Paste your JSON into the editor.
- Choose indent 2, indent 4 or Minify.
- If something is invalid, fix it at the marked position.
Frequently asked questions
What does minify mean?
It removes spaces and line breaks so the JSON takes up less space.
Why is my JSON often invalid?
The most common causes are trailing commas, single quotes and stray comments.
Is my JSON safe?
Processing is local, and your data isn't sent to a server.
JSON structure choices that pay off later
Arrays vs objects, key order, duplicate keys — the decisions that shape every consumer of the data. · 5 min read
Object or array at the top?
An object ({}) models a thing with named properties; an array ([]) models an ordered list of things. The classic mistake is encoding lists as numbered objects: {"1": {...}, "2": {...}} — that pattern exists only because someone wanted 'stable order', but JSON objects have no guaranteed order. Consumers that iterate numerically over such keys fight the format; use an array and let order be order. The flip side: when you need random access by identifier, an object keyed by id is genuinely better than an array you linearly search.
Order, duplicates and other quiet traps
JSON says nothing about key order — two objects with the same keys in different orders are equal, and formatters sort or preserve keys depending on their settings; this tool's diff mode is deliberately key-order insensitive. Duplicate keys are technically representable and behaviorally undefined: most parsers keep the last one, which is why machine-edited JSON with duplicated keys is a real production hazard. Trailing commas, single quotes, unquoted keys — all legal in JavaScript, all invalid JSON; the formatter pinpoints the line and column of the first offense.
Formatting is for humans
Minified JSON (no whitespace) saves bandwidth — a typical API response shrinks 20–30% — but costs eyeballs. The right default: store and transmit minified, format on demand when a human reads it. And when diffing two JSON payloads, prefer a canonical comparison (keys sorted, whitespace normalized) — that's the only way to see real structural differences instead of formatting accidents.