Why format JSON?
APIs, logs and many config files store JSON on a single line to save space. That's perfect for machines but impossible to read: you can't tell which object sits inside which, or where an array ends.
This formatter (also called a JSON beautifier or pretty printer) rewrites the JSON with one value per line and 2-space, 4-space or tab indentation, so you can see the structure at a glance. Turn on “Sort keys A-Z” and the keys of every object are put in alphabetical order, which is handy when comparing two responses.
Numbers are kept exactly as they were written. Many formatters run JSON through JavaScript and round very long integers (a 19-digit ID, for example); that doesn't happen here. If the JSON is invalid, you get the error in plain English, the line and column, and a button that puts your cursor right on it.
How to format JSON
- Paste the JSON into the input box, drag in a .json file or click “Open file”.
- Pick the indentation: 2 spaces, 4 spaces or tab.
- Optionally, turn on “Sort keys A-Z”.
- Click “Format JSON”, then copy the result or download it as a file.
When to use it
- Reading an API response that arrives on a single line.
- Checking a package.json, tsconfig.json or other config file before you commit it.
- Comparing two JSON responses with their keys in the same order.
- Finding the line with the error in a JSON file your program rejects.
Frequently Asked Questions
What's the difference between formatting and validating JSON?
Formatting changes the layout (line breaks and indentation) without touching the data. To format it, the tool also has to parse it, so if the JSON is invalid it shows you the error. If you only want to know whether it's valid and see its stats, use the JSON validator.
Does formatting change any values?
No. Only whitespace and line breaks change. Numbers are copied as-is, without rounding, and strings keep their content. If you turn on “Sort keys”, the order of the keys changes, not their values.
Can I format JSON with comments or trailing commas?
No, because that isn't valid JSON (it's JSON5 or JSONC). The tool tells you which line the comment or extra comma is on so you can remove it.
Is my data sent to a server?
No. Everything is processed in your browser with JavaScript. The text you paste and the files you open never leave your device, so you can safely work with internal or customer data.
Can I format several files at once?
Yes, with ToolStudio Pro. Open several .json files together, they're formatted with the same options and you download them all in one ZIP. The free try covers one document.
Is it free?
Yes. You can try the tool for free on one document (pasted or a single file) and change the options as often as you like; attempts that end in an error don't use up your free try. For unlimited use and processing several files at once, ToolStudio Pro costs €1.99 a month and includes every tool.