TOOLS WORLD logoTOOLS WORLD

JSON Formatter

Paste messy or minified JSON and get clean, readable output with your choice of indentation. Format, minify, copy, and download JSON in one click.

Output
Formatted JSON appears here

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

  1. 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.
  2. Choose an indentation style from the dropdown - 2 spaces (the JavaScript ecosystem default), 4 spaces, or tabs.
  3. Click Format to pretty-print the JSON, or Minify to strip all whitespace and produce the smallest possible output.
  4. 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.
  5. Copy or download the result using the Copy button above the output panel or the Download button, which saves a formatted.json file.

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, and undefined are not valid JSON values. Use null or 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 errors array.
  • 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.

Frequently asked questions

Is it safe to paste sensitive JSON into this formatter?
Yes. This JSON formatter runs entirely in your browser using JavaScript's built-in JSON.parse and JSON.stringify functions. Your data is never uploaded, transmitted, or stored on any server, so it is safe to format API responses, configuration files, or payloads that contain private information.
What is the difference between formatting and minifying JSON?
Formatting (also called beautifying or pretty-printing) adds line breaks and indentation so the structure is easy for humans to read. Minifying does the opposite: it removes all unnecessary whitespace to make the file as small as possible, which is ideal when sending JSON over the network or storing it. Both operations produce semantically identical JSON.
Why does the formatter say my JSON is invalid?
The most common causes are trailing commas after the last item in an object or array, single quotes instead of double quotes around strings and keys, unquoted keys, comments (JSON does not allow them), and special values like NaN or undefined. The error message shows the line and column where parsing failed so you can jump straight to the problem.
Does formatting change the order of my JSON keys?
No. The formatter preserves the original order of keys exactly as they appear in your input. It only changes whitespace - indentation, spaces, and line breaks - never the data itself.
Is there a size limit for the JSON I can format?
There is no hard limit imposed by the tool. Because everything runs locally, the practical limit depends on your device's memory. Documents of several megabytes format instantly in modern browsers; extremely large files (hundreds of megabytes) may be slow or fail, and are better handled with command-line tools like jq.
Should I use 2 spaces, 4 spaces, or tabs for JSON indentation?
It is purely a readability preference. Two spaces is the most common convention in the JavaScript ecosystem and keeps deeply nested structures compact. Four spaces is easier to scan for some readers, and tabs let each developer choose their own display width. Match whatever convention your team or project already uses.
Can this tool fix broken JSON automatically?
No, and that is intentional. Automatically 'fixing' JSON can silently change your data in ways you did not intend. Instead, the formatter reports the exact line and column of the first syntax error so you can correct it yourself and be confident the result is exactly what you meant.

Related tools

More free tools you might find useful alongside the JSON Formatter.