Skip to content

JSON Formatter & Beautifier - Format JSON Online

Indent:
Input JSON
Formatted Output

Pretty-Print JSON

Paste minified or badly indented JSON on the left and a formatted, syntax-highlighted version appears on the right. Pick the indent width above the editor, then copy the result. A minified API response like this:

{"user":{"id":8812,"roles":["admin","billing"],"active":true},"next":null}

becomes:

{
  "user": {
    "id": 8812,
    "roles": [
      "admin",
      "billing"
    ],
    "active": true
  },
  "next": null
}

Why Exact Re-Indenting Matters

The quick way to format JSON in JavaScript is JSON.stringify(JSON.parse(text), null, 2). It works for most data, but it rounds integers above 253, so Twitter and Discord snowflake IDs, 64-bit database keys and some order numbers come out with the wrong last digits. It also rewrites 1.0 as 1 and 1e3 as 1000. This formatter only changes whitespace between tokens, so what you copy out holds exactly the values you pasted in. A byte-order mark at the start of the file, which some Windows editors add, is removed.

Common Errors It Catches

  • Trailing commas: [1, 2, 3,] is fine in JavaScript but not in JSON.
  • Single quotes: {'name': 'Ann'} needs double quotes.
  • Unquoted keys: {name: "Ann"} is a JavaScript object literal, not JSON.
  • Python output: True, False and None must be true, false and null.

For line-by-line error details use the JSON validator. To collapse and explore a large document, open it in the JSON tree viewer, and to compare two versions use JSON diff.

Related Tools

Frequently Asked Questions

Can I choose the indentation?
Yes: 2 spaces (the default), 4 spaces, 8 spaces or tabs. Switch to Minify to go the other way and put everything on one line.
Will formatting change my numbers or key order?
No. The formatter re-indents your original text instead of parsing it into JavaScript values and printing them again. An ID like 12345678901234567890 stays exact (JSON.stringify would print 12345678901234567000), 1.0 stays 1.0, and keys keep their order. Duplicate keys are kept too, though most parsers will only keep the last one.
What happens if my JSON is invalid?
Nothing is formatted, and the error from your browser's JSON parser is shown, with a line and column where the browser reports one. The usual culprits are trailing commas, single quotes around strings, unquoted keys and comments. For more detail on each error, use the JSON Validator.
Can it format JSON with comments (JSONC)?
Not directly, because comments are not valid JSON. Paste the file into the JSON Minifier with "Strip comments" on, switch it to Beautify, and you get formatted JSON without the comments or trailing commas.
Is my data sent to a server?
No. Formatting runs in your browser, so API responses with tokens or customer data never leave your machine. Files of a few megabytes format without trouble; very large files are limited only by your browser's memory.