JSON Formatter and Minifier
Pretty-print, minify, and optionally sort keys in JSON — right in your browser. Pick 2-space, 4-space, or tab indentation, and get a precise line and column when the input fails to parse.
Input
Result
What this tool does
This is a JSON formatter: it reads a JSON document, parses it once with the browser's native JSON.parse, and re-emits it the way you ask. Pretty-print produces readable, indented output; minify collapses it to the smallest equivalent string; and the optional sort-keys pass reorders object keys recursively so two payloads diff cleanly. Because every mode parses first, the tool doubles as a fast validity gate — if the input is not well-formed JSON, you get a precise error instead of mangled output.
It is deliberately distinct from the JSON validator. The validator is about checking a document against a schema and reporting structural findings; this page is about transforming the output you already have. Reach for this tool when you have a blob of minified JSON from a network trace and want to read it, or a hand-edited config that needs to be normalised before committing.
When to use it
Pretty-print when you have captured a one-line response body — from an API log, a smart-card management server, or a WebAuthn ceremony trace — and need to see its shape. Minify before embedding JSON in a constrained field, a QR payload, or a URL where every byte counts. Sort keys before diffing two configuration files whose authors emitted fields in different orders, so the diff shows real changes rather than reordering noise. For binary-adjacent formats, the CBOR decoder turns a compact binary encoding into JSON you can then format here.
Input and output
The input is any valid JSON value: an object, an array, a string, a number, a boolean, or null. Whitespace, indentation, and line endings in the input are irrelevant — the parser ignores them, so you can paste minified or already-indented text. The output reflects your chosen mode and indent. Pretty-print uses your indent setting (two spaces, four spaces, or a literal tab) for every nesting level; minify ignores the indent setting entirely and emits no optional whitespace. The decoded value is preserved exactly: strings, number precision within IEEE-754 limits, and key sets are unchanged — only layout and, optionally, object-key order change.
When the input cannot be parsed, the result panel shows a parse error with a line and column. The position is taken from the offset the browser reports for the syntax error; the tool walks the text to that offset, counting newlines to give a one-based line and column. If the browser does not supply an offset, the raw engine message is shown so you still know what broke.
Common mistakes
- Trailing commas.
[1, 2, 3,]and{"a": 1,}are valid in JavaScript object literals but invalid JSON. Remove the comma before the closing bracket. - Single quotes. JSON requires double quotes around every string and key.
{'a': 1}will fail to parse. - Comments. Standard JSON has no comments;
//and/* */are rejected. Strip them before formatting. - Unquoted keys.
{a: 1}is not JSON. Every key must be a double-quoted string. - Expecting sorted arrays. Sort keys only reorders object members. Arrays are ordered by definition and are left exactly as they are.
Related tools
JSON Validator
Check a document against a JSON Schema and report structural findings.
JSON Bin Builder
Compose and inspect binary-bearing JSON payloads field by field.