An API response arrives as one long line. A config file has been edited by three people with three habits. Either way, you want JSON that is easy to read, or as small as possible for transport.
What the formatter does
Paste JSON into the JSON Formatter and it re-indents it. Take {"b":2,"a":[1,2,{"c":null}]}. With a two-space indent it becomes:
{
"b": 2,
"a": [
1,
2,
{
"c": null
}
]
}
Tick minify and you get the compact form back: {"b":2,"a":[1,2,{"c":null}]}.
The options
- Indent: 2 spaces, 4 spaces or a tab. Follow your project’s convention.
- Minify: removes all optional whitespace. Smaller files transfer faster, and the content is unchanged.
- Sort keys: orders object keys alphabetically at every level.
{"b":2,"a":1}becomes{"a": 1, "b": 2}on separate lines. Sorting makes two similar files easier to compare in a diff.
Formatting never changes values. It only changes whitespace, and key order if you ask for it. Keep in mind that JSON objects are unordered by definition, but some programs still read keys in order, so only sort when order does not matter.
When there is an error
If the input is not valid JSON, the formatter reports the line and column of the problem and the parser’s message instead of producing output. A trailing comma, as in {"a":1,}, is one of the most common mistakes. For a longer list of causes, see how to validate JSON.
Using the tool
- Paste your JSON.
- Choose the indent, and tick minify or sort keys if needed.
- Copy or download the result.
Your data stays in your browser. Even so, avoid pasting live secrets such as API keys into any online tool you do not control.
Frequently asked questions
Is a very large file a problem?
Browsers can handle large files, but the page may slow down. For files of many megabytes, a command-line tool is more comfortable.
Does it accept JSON with comments?
No. Standard JSON has no comments, so they are reported as errors. Remove them first.