The JSON formatter is the second tool on the site and the one we reach for most often ourselves. It does four things, each of which sounds trivial until you need it at eleven at night with a broken API response in front of you. This post explains what each does, how it works, and the habits it was designed around.
Why we built it
The same reason as the UUID generator. Existing formatters were slow, full of ads, or quietly sent your JSON to a server. The last one matters more for JSON than for UUIDs, because the JSON you format is usually real data: an API response with customer records, a config file with connection strings, a webhook payload with an order in it. Pasting that into a stranger's server to add some line breaks is a bad trade.
So the formatter runs entirely in the page. It uses the browser's own JSON.parse and JSON.stringify, which are fast, correct and already on your machine. There is no upload, no history on our side, nothing to delete later.
The four jobs
- Format. Takes a minified blob and pretty prints it with the indent you choose: two spaces, four spaces or tabs. Servers strip whitespace to save bandwidth, and formatting puts the structure back so you can see where a field lives.
- Validate. Checks the text without changing it and tells you exactly what is wrong. More on the error messages below.
- Minify. The reverse of format. Strips every unneeded space and newline so the text is as small as it can be before you store it, send it, or paste it into a prompt. For a large document that is often a third smaller, which also means fewer tokens when the JSON goes to a language model.
- Sort keys. Walks the whole structure and orders every object's keys alphabetically, at every level. Two documents from different sources often have the same data in a different order, and sorting both makes a diff meaningful. It is also the quickest way to find a field in a big object.
Three smaller conveniences: Load Sample drops in a realistic document so you can try the buttons, Clear resets both boxes, and Copy Output grabs the result.
Error messages that point at the problem
Most formatters say "invalid JSON" and leave you to find the missing comma in 400 lines. This one reports the line and column where the parser stopped, so you can jump straight there. The browser's parser only reports a character position, so the tool counts the newlines before that position to turn it into a line number, and the distance from the last newline into a column. Newer browsers include line and column in the message themselves, and the tool uses that when it is available.
The errors it catches most often are the ones every developer has made: a trailing comma after the last item, single quotes instead of double, an unquoted key, a comment, a raw line break inside a string. Our guide to JSON syntax rules and the ten most common errors explains each one and how to fix it.
Habits it supports
- Debugging an API. Paste the raw response, click Format, read it. If the response is not valid JSON, which happens when a server returns an HTML error page, the validator tells you on line one.
- Comparing two configs. Sort Keys on both, then diff them in your editor. Differences that were hidden by key order disappear.
- Shrinking JSON before it goes somewhere. Minify before storing a document in a column, before committing a fixture, or before pasting it into an AI prompt. Our post on reducing token usage explains why whitespace costs money.
- Learning JSON. The guide under the tool covers the six value types, why formatting matters, the difference between JSON and a JavaScript object, and how the tool itself works.
Limits, honestly
It is a text tool. It will format a few megabytes without complaint, but it is not a viewer for a 200 MB log file, and it does not fold or search the tree. Those jobs belong to the JSON visualizer, which draws the document as a diagram. The formatter also does not repair JSON. When it says line 12 column 8, fixing that is up to you, which is the right division of labour for a tool that touches production data.
What is next
Converters next to the formatter: JSON to CSV, JSON to YAML, and JSON to TypeScript types, each as its own page with the same no upload rule. If you need a conversion we have not listed, the contact page is open.