JSON Formatter & Validator
Beautify or minify JSON, and when it is invalid, get told exactly where the problem is and what usually causes it.
The error message is the feature
Formatting valid JSON is easy and every tool does it. The reason anyone opens a JSON formatter in a hurry is that something is broken, and this is where most tools give up: they print whatever the browser threw, which might be "Unexpected token } in JSON at position 1482" and might, in a different browser, be a message with no position in it at all. A character offset is not much use against a wall of minified JSON. This page turns the failure into a line and column, shows you the text on either side of the problem with the spot marked, and adds the usual cause when the message is one of the recognisable ones.
The three mistakes that account for almost everything
A trailing comma before a closing brace or bracket is the most common by far, because JavaScript allows it and JSON does not, so code that works becomes data that fails. Single quotes are next: JSON strings must use double quotes, always, including around property names. Third is a document that simply stops early, usually because something was truncated in transit or two documents were pasted together. Each of these produces a different message in each browser, and each is recognised here and explained in plain words next to the position.
Sorting keys, and why arrays are left alone
Sorting object keys alphabetically is the fastest way to make two versions of the same document comparable, which is usually why anyone wants it: a diff of two API responses becomes readable the moment both are formatted and sorted the same way. Arrays are deliberately never reordered. The order of an object's keys carries no meaning in JSON, but the order of an array is part of what the document says, and a tool that quietly sorted arrays would change your data while claiming to tidy it.
Minifying, and what it is worth
Minifying strips every space and newline that a machine does not need. On a large API payload that is often 20 to 30 percent of the bytes, which matters over a mobile connection and matters again when the same document is stored a million times. The counter tells you exactly what you saved. It is worth knowing that on a properly configured server compression will recover most of the same bytes on the wire anyway, so minifying is most useful for storage, for embedding a document in a file, and for pasting into somewhere with a length limit.
Big numbers, a real limitation to know about
JSON numbers have no size limit in the specification, but JavaScript parses them as doubles, which are exact only up to about nine quadrillion. A 20-digit identifier in your document will come back changed by a digit or two after a round trip through any browser-based tool, this one included. It is not a bug that can be fixed here, and it is the reason well-designed APIs send long identifiers as strings. If your document contains one, format it here by all means, but do not paste the result back as your source of truth.
Nothing is uploaded
API responses are exactly the kind of thing that contains customer names, email addresses and tokens. This page parses your document in the tab, so none of that leaves your machine, and you can confirm it by disconnecting from the network and formatting anyway.
Frequently asked questions
Where does it tell me the error is?
It converts whatever the browser reports into a line and column, prints the text on both sides of the spot with a marker, and adds the usual cause when the error is a recognisable one such as a trailing comma or a single-quoted string.
Why does my JSON with single quotes fail?
Because JSON requires double quotes on every string, including property names. Single quotes are valid JavaScript but not valid JSON, which is why code that runs can still produce data that will not parse.
Does sorting keys change my data?
No. The order of keys in a JSON object carries no meaning, so sorting them is safe and makes two documents comparable. Arrays are never reordered, because the order of an array is part of what the document says.
What happens to very large numbers?
They lose precision, in this tool and in every other browser-based one, because JavaScript stores numbers as doubles that are exact only to about 16 digits. If your document has 19 or 20 digit identifiers, treat the formatted output as a view, not as a replacement for the original.
Is my JSON sent to a server?
No. Parsing, formatting and minifying all happen in this tab, which matters because API payloads routinely contain personal data and access tokens.

