API responses and config files usually arrive as a single unbroken line of JSON, which is hard to read and harder to debug. This formatter parses the text with the browser's own JSON parser and prints it back with consistent indentation, so nesting becomes obvious at a glance. If the text is not valid JSON, you get the parser's exact message together with the line and column where it gave up, which is normally enough to spot a trailing comma or a missing quote.
Beyond pretty printing, the tool can go the other way and strip every optional space and newline for a compact payload, and it can sort object keys alphabetically at every level so two versions of the same document can be compared line by line. The stats row reports the byte size before and after, the total number of object keys, and the deepest level of nesting. Nothing is uploaded and the parser is JSON.parse, never eval.
How to use the JSON Formatter
- Paste your JSON into the input box, or click Load sample to see how it works.
- Pick an indent of 2 spaces, 4 spaces or a tab, or tick Minify to collapse everything onto one line.
- Tick Sort keys alphabetically if you want a stable key order for comparing two documents.
- Click Format JSON. If the text is invalid, read the reported line and column, fix it, and run it again.
Frequently asked questions
Why does my JSON fail to parse when it looks fine?
The usual causes are a trailing comma after the last item, single quotes instead of double quotes, unquoted keys, or a stray comment. JSON allows none of those. The reported line and column point at the first character the parser could not accept, so check just before that spot.
Does minifying JSON make it meaningfully smaller?
It removes indentation and newlines, which on a deeply indented document can cut 20 to 50 percent of the bytes. Over HTTP most of that is redundant because gzip or brotli compresses repeated whitespace very well, so minified JSON is mainly useful for storage and for embedding in files.
What does maximum nesting depth mean?
It counts how many levels of objects and arrays sit inside each other, with the top level counted as zero. Deep nesting is legal but many parsers, databases and APIs set a limit, so the number is a quick sanity check before you send a document somewhere else.
Is my data sent to a server?
No. The formatting, validation and sorting all happen in your browser with JavaScript. No request is made and nothing is stored, so you can safely paste API responses that contain tokens, customer records or other private values.