JSON Formatter
Format, minify, and validate JSON — copy and paste the result.
This free online JSON formatter pretty-prints or minifies JSON, with adjustable indentation and recursive key sorting. Invalid JSON shows a clear error with line and column when your browser can pinpoint it. No signup required, runs entirely in your browser.
Mode
Indent
Sort keys
Sort object keys alphabetically, recursively through the whole document.
What does a JSON formatter do?
A JSON formatter takes JSON text and re-outputs it with consistent, readable indentation — turning a dense, single-line API response into something you can actually scan. This tool validates the input first, so if your JSON has a syntax error, you get a clear message instead of a broken or empty result.
Format vs minify
Format (pretty-print) adds indentation and line breaks so nested objects and arrays are easy to read — pick 2 spaces, 4 spaces, or a tab. Minify does the opposite: it strips every unnecessary space, tab, and newline, producing the smallest possible valid JSON — useful when you're about to send the payload over the network or store it and don't need it to be human-readable.
Sorting keys
Turn on Sort keys to alphabetize every object's keys, recursively — including objects nested inside arrays. This is especially useful when comparing two JSON documents that contain the same data but were generated with keys in a different order; sorting both first makes a text diff meaningful instead of showing every key as moved.
Common JSON syntax errors
- Trailing commas —
{"a": 1,}is invalid; JSON doesn't allow a comma after the last item. - Single quotes — JSON requires double quotes for strings and keys;
{'a': 1}is invalid,{"a": 1}is valid. - Unquoted keys —
{a: 1}is invalid JavaScript-object-literal syntax but not valid JSON; keys must be quoted strings. - Missing or extra brackets — every
{/[needs a matching}/].
This tool uses your browser's native JSON parser, so error messages match exactly what you'd see in the browser console — including the line and column when the parser can determine one.