JSON Formatter

Format, validate and minify JSON in your browser. Nothing is uploaded.

Input

0 chars
Runs in your browser
Output
 
Top-level keys
—
Max depth
—

Formula & explanation

What it does. Paste any JSON and get a readable, indented version in one click. The tool parses the text, validates the syntax, and if the JSON is invalid it points to the problem instead of silently failing. It also reports the output size in bytes, the number of top-level keys, and the maximum nesting depth — a quick way to spot a structure that grew deeper than you expected.

Indent or minify. Pick 2 spaces, 4 spaces or a tab to pretty-print, or choose Minified to strip all whitespace and produce the smallest possible payload — useful before pasting JSON into a config, a URL parameter or a size-sensitive field. Turn on Sort keys to alphabetize object keys, which makes two API responses easy to diff when they return fields in a different order.

Why do it in the browser. Everything runs locally — the JSON never leaves your device. That matters because real-world JSON you need to read is often a production API response with tokens, internal IDs or personal data. A formatter that only transforms text has no reason to upload it, so this one doesn't.

Example

Indentation2
Output size0 KB
Top-level keys3

Frequently asked questions

Is my JSON sent to a server?

No. Parsing and formatting happen entirely in your browser; nothing is uploaded, so it's safe to paste a real production payload.

Why does it say invalid JSON?

Common causes: trailing commas, single quotes instead of double quotes, unquoted keys, or a stray comment. JSON is stricter than a JavaScript object literal.

What's the difference between formatting and minifying?

Formatting adds indentation and line breaks so humans can read it. Minifying removes all optional whitespace so machines transfer it faster and smaller. Same data, opposite goals — pick based on who reads it next.

Does it keep the key order?

Yes, unless you enable 'Sort keys alphabetically', which is handy for diffing two responses that list fields in different orders.

Does it preserve very large numbers (IDs, timestamps)?

No. JavaScript's JSON.parse converts numbers above 2^53-1 (~9 quadrillion) to the nearest double, losing precision. For large IDs, keep them as strings in your JSON.

What happens with duplicate keys in the same object?

Only the last value is kept (JavaScript object behavior). If you need all values, your data shouldn't use duplicate keys.

What does the 'max depth' output mean?

It's how many levels deep the most-nested value sits. A surprise depth often means an object or array nested further than you intended — a quick sanity check on a config or payload.

Related tools