What the JSON Formatter does
JSON Formatter turns one long line of JSON into readable, indented text, and back again, without sending anything to a server. Paste an API response body, a config blob or a log line, then use Format to re-indent it with two spaces per nesting level, Compress to strip every optional space, or Validate to check whether the text parses at all. Parser errors come back in your browser's own wording.
A full cycle looks like this. You paste {"user":{"id":7,"roles":["admin","editor"]},"active":true} and press Format; the result panel shows the object spread over lines, each level indented two spaces. Press Compress on that formatted text and you get the single line back, plus a percentage saved and the character count of the compressed output.
How to use it
- Paste JSON in the boxThe textarea arrives prefilled with a small sample so the buttons do something useful immediately. Replace it with your own payload; there is no file upload, so open your file and paste the contents.
- Press Format to indentFormat parses the text and reprints it with two-space indentation. On success the stats line confirms valid JSON and reports the input size in bytes or KB; on failure it prints the parser message.
- Use Compress for one lineCompress drops whitespace between tokens, giving the smallest text this tool can produce, then reports the compressed character count and the percentage reduction measured against what you pasted in.
- Validate before you shipValidate parses without reprinting, so it answers a yes-or-no question. The result box shows either the confirmation message or the parser error, while the JSON you typed stays exactly as it is.
Options and formats
Things to watch out for
Frequently asked questions
Why does my JSON fail here but work in JavaScript?
JavaScript object literals are looser than JSON. Trailing commas, single quotes, unquoted keys, comments and undefined are all legal in code and all illegal in JSON. If the text came from a source file, clean up those constructs or convert it first.
Can I copy the result with one click?
Not from a button; the result box is read-only text. Select it with the keyboard, or click inside and use select all, then copy. Long results scroll inside a fixed-height panel, so select-all beats dragging across the visible portion.
Does it change the order of keys?
Almost never. Whitespace is the only intended change, and values and types are untouched. One quirk: numeric-looking keys such as "1" and "2" are reordered into ascending numeric order by the browser engine, while other keys keep insertion order.
Is there a size limit?
There is no built-in limit, but parsing happens on the main thread, so a multi-megabyte payload can freeze the page while it completes. Very large documents are better handled by a desktop editor or a streaming parser.
What does the size figure actually measure?
The bytes of the text you pasted, computed before parsing and shown in B or KB. Compress reports something different: the character count of its own output and the percentage saved. The two numbers are not directly comparable.
Can I keep fixing the JSON after an error?
Yes. Edit the input and press any button again as often as you like, and each attempt replaces the previous result. The parser message names the first offending token, which is usually enough to find a stray comma or quote.