JSON Formatter

Pretty-print or minify any JSON document, with optional alphabetical key sorting. Runs entirely in your browser — no upload required.

INDENT
INPUTUTF-8 / Raw
OUTPUT
// formatted JSON appears here

What "format JSON" really means

A JSON document is just a string that respects a strict grammar. The same data can sit on one line, be indented with two spaces, with four, or sprawled across hundreds of lines with sorted keys — every one of those forms decodes to the same value.

Formatting re-emits the document in a chosen style while leaving the data untouched. This page uses the browser's native JSON.parse and JSON.stringify — deterministic, reproducible, byte-for-byte identical on any machine.

Zero latency

Your JSON never leaves your computer. Everything happens locally in the browser's JavaScript engine. Open the network panel and click Format — zero requests.

Privacy first

No servers, no tracking, no logging of your payload. Your production JSON stays in this tab's memory and disappears when you close it.

Common questions

What does "format JSON" actually do?
It re-emits the same data with consistent indentation and one key per line, or strips every optional byte of whitespace if you minify. The data itself never changes — only its rendering.
Should I use 2 spaces, 4 spaces, or tabs?
Match your repository convention. JavaScript / TypeScript / npm default to 2 spaces. Python and .NET lean to 4. Go uses tabs. Consistency beats preference.
Why minify if my server can gzip?
Gzip catches most of the win on the wire, but minified JSON matters in localStorage, IndexedDB, JWT payloads, URL state — anywhere a non-compressing consumer reads the document at rest.
Does it sort keys?
Toggle "Sort keys" to alphabetize every object at every level. Useful for deterministic diffs, reproducible builds, and stable file hashes. Array order is preserved — arrays in JSON are ordered by definition.
How big a file can I throw at this?
A few tens of megabytes work on a desktop. The browser allocates the whole tree in memory; multi-gigabyte logs need a streaming tool like jq, fx, or Python ijson.
What if my input is broken?
You get the exact line and column of the failure. Fix the usual suspects (trailing commas, single quotes, unquoted keys) and retry, or use the validator for a clearer error view.