What is a JSON formatter?
A JSON formatter (also called a JSON beautifier or pretty-printer) takes raw JSON text and rewrites it with consistent indentation and line breaks so that humans can actually read it. JSON - JavaScript Object Notation - is the standard data format of the modern web. APIs return it, configuration files use it, databases export it, and log pipelines emit it. The problem is that machines usually produce JSON in minified form: a single unbroken line with every space stripped out to save bandwidth. A 50-field API response collapsed onto one line is nearly impossible to inspect by eye.
This tool solves that in one click. Paste any valid JSON - minified, inconsistently indented, or copied out of a terminal - and it produces clean, consistently indented output. You can choose between 2-space, 4-space, or tab indentation, minify in the other direction, copy the result to your clipboard, or download it as a .jsonfile. Everything happens locally in your browser using the JavaScript engine's native JSON.parse and JSON.stringify, which means it is fast, accurate to the JSON specification, and completely private.
How to use the JSON formatter
- Paste your JSON into the input panel on the left. You can paste minified JSON, messy hand-edited JSON, or click Load sample to try the tool with example data.
- Choose an indentation style from the dropdown - 2 spaces (the JavaScript ecosystem default), 4 spaces, or tabs.
- Click Format to pretty-print the JSON, or Minify to strip all whitespace and produce the smallest possible output.
- Review the output in the right panel. If your input is not valid JSON, an error message appears below the buttons with the exact line and column of the first problem.
- Copy or download the result using the Copy button above the output panel or the Download button, which saves a
formatted.jsonfile.
Examples
Before: minified API response
{"user":{"id":42,"name":"Ada","tags":["admin","eng"],"active":true}}After: formatted with 2-space indentation
{
"user": {
"id": 42,
"name": "Ada",
"tags": [
"admin",
"eng"
],
"active": true
}
}The reverse is just as useful. If you have been editing a readable configuration file and need to embed it in an environment variable, a query string, or a compact request body, click Minify and the formatted document above collapses back to a single 68-character line.
Why formatting JSON matters
Well-formatted JSON is not just cosmetic. Debugging is dramatically faster when the structure of a payload is visible at a glance: nesting depth, array boundaries, and missing fields all become obvious. Code reviews of configuration changes are more reliable when diffs align line-by-line instead of showing one gigantic changed line. And when you are learning an unfamiliar API, pretty-printed responses are the quickest way to understand the shape of the data it returns.
Minification matters for the opposite reason: whitespace is wasted bytes on the wire. Stripping it from a large payload can shrink it by 10–20% before compression even starts, which adds up across millions of requests.
Common JSON syntax mistakes
JSON looks like JavaScript but is much stricter. If the formatter reports an error, it is almost always one of these:
- Trailing commas -
{"a": 1,}is invalid. JSON does not allow a comma after the last element. - Single quotes -
{'key': 'value'}is invalid. All strings and keys must use double quotes. - Unquoted keys -
{key: 1}is valid JavaScript but invalid JSON; write{"key": 1}. - Comments - neither
//nor/* */comments are allowed anywhere in a JSON document. - Special values -
NaN,Infinity, andundefinedare not valid JSON values. Usenullor a string instead.
If you only want to check whether a document is valid without reformatting it, use the dedicated JSON Validator, which is built around detailed error reporting.
Tips for working with JSON
- Format JSON before committing configuration files so diffs stay small and reviewable.
- When an API returns an error you do not understand, format the full response - the useful detail is often buried in a nested
errorsarray. - Use minified JSON for anything transmitted or stored at scale, and formatted JSON for anything a human will read.
- Generating test data? Pair this tool with the UUID Generator to create realistic unique identifiers for your fixtures.
- Extracting values from JSON strings with patterns? The Regex Tester lets you prototype the expression against real sample text first.