Developer Tools

JSON Formatter

Pretty-print JSON with 2 or 4 space indentation, sort keys for stable diffs, and catch syntax errors as you type — all in your browser.

100% browser-side processing — nothing is uploaded

Format: Pretty-print JSON with stable indentation. Output updates live as you type — or press Ctrl/Cmd + Enter.

Results update live as you type.
14 lines · 0.29 KB
1 lines · 0.00 KB

Related tools

How to format JSON

  • Paste JSON

    Drop your raw or minified JSON into the input editor. It validates live as you type.

  • Choose indentation

    Pick 2 or 4 spaces. Optionally use Sort Keys for alphabetical, diff-stable ordering.

  • Copy the result

    The formatted output appears instantly — copy it, download it, or minify it back.

Why pretty-printing matters more than it looks

A minified API response is correct but unreadable — one 40 KB line where a missing field could hide anywhere. Formatting re-serializes the same data with consistent indentation so structure becomes visible: nesting depth reads as horizontal position, siblings align, and a missing brace announces itself. Because the formatter parses and re-emits rather than editing text, the output is guaranteed-valid JSON with exactly the same data; only whitespace changes.

Sort keys when files live in version control

JSON objects have no guaranteed key order, so two serializations of identical data can produce a noisy git diff. Recursively sorting keys A→Z makes serialization deterministic: config files, lockfile-style manifests, and API fixtures diff cleanly commit after commit. Sorting only reorders object keys — array order is data, so arrays are left exactly as they are.

JSON Formatter FAQ

Does formatting change my data?

No. The formatter parses your JSON and re-serializes it with new whitespace. Values, key names, array order, and structure are byte-for-byte equivalent — only indentation and line breaks change.

Should I use 2 or 4 space indentation?

Two spaces is the dominant convention in the JavaScript ecosystem (npm, Prettier defaults). Four spaces reads more easily for deeply nested payloads. Both produce identical data — pick what your team already uses.

What does Sort Keys do to arrays?

Nothing. Array order carries meaning in JSON, so sorting only applies to object keys, recursively at every level. Arrays keep their original element order.

Is my JSON uploaded anywhere?

No. Formatting runs entirely in your browser with JavaScript. Nothing is sent to a server, so pasting production payloads or data with tokens is safe.

Why does my input show an error?

The live validator applies strict JSON rules: double-quoted keys, no trailing commas, no comments, no single quotes. The error message names the line and column, and the editor gutter marks the line — click "Go to line" to jump there.