JSON Formatter and Validator

Paste messy JSON, get clean, readable output, or squeeze it down to a single line.

Indent

Result

How to use the JSON formatter

Paste your JSON into the JSON formatter’s input box, whether it came from an API response, a log file or a config you are editing. Then choose an action. Format re-indents the data with either 2 or 4 spaces per level, putting each key on its own line so the structure is easy to follow. Minify does the opposite and strips all optional whitespace, which is handy before you embed JSON in a URL, an environment variable or a request body.

When the result looks right, press the copy button to put it on your clipboard. Everything runs locally in the browser tab, so the JSON formatter is safe to use with access tokens, internal endpoints or personal data that should never be uploaded to a third-party service.

How it works

The tool first parses your text with the browser’s built-in JSON parser, the same strict one that JSON.parse uses in JavaScript. If parsing succeeds, the data is printed back out with the indentation you picked, or with none at all for minify. Because the output is generated from the parsed data rather than by shuffling characters around, the result is always valid JSON.

If parsing fails, you get the line and column where the parser gave up. That position usually points to the character right after the real mistake, so look at the end of the previous line as well.

A small before-and-after example with 2-space indentation:

{"order":1042,"items":[{"sku":"MUG-01","qty":2}],"paid":true}
{
  "order": 1042,
  "items": [
    {
      "sku": "MUG-01",
      "qty": 2
    }
  ],
  "paid": true
}

Fixing common JSON errors

One more thing worth knowing: the formatter validates your JSON with the browser’s parser but reprints it from the original text tokens rather than re-serializing parsed JavaScript numbers. That means a very large integer, a trailing zero like 1.10, or a -0 keeps its exact original digits instead of being rounded or rewritten the way JSON.stringify(JSON.parse(x)) would do it.

Frequently asked questions

Is my JSON sent to a server?

No. Formatting and minifying happen entirely in your browser, so API keys, tokens or customer data you paste never leave your device.

Should I use 2 or 4 spaces?

Two spaces is the common choice for JavaScript projects and keeps deeply nested data compact. Four spaces is easier to scan in short files and matches many Python and Java style guides.

Why does the formatter reject my JSON when JavaScript accepts it?

JSON is stricter than JavaScript object syntax. It requires double quotes around keys and strings and does not allow trailing commas, comments or undefined.

What does minify do?

It removes every space and line break that is not part of a string value, producing the smallest valid version of the same data.