JSON formatter

Paste minified or messy JSON and get readable, consistently indented output, with errors pinned to a line and column.

Tier 0 · browser · unlimited
100 characters
Output
{
  "user": {
    "id": 42,
    "name": "Ada Lovelace",
    "roles": [
      "admin",
      "dev"
    ]
  },
  "active": true,
  "score": 9.5,
  "tags": []
}
Root typeobject
Keys7
Nesting depth3

Why format JSON

APIs and logs usually send JSON on a single line to save bytes. That is fine for machines and unreadable for people. Formatting adds line breaks and indentation so nesting is visible at a glance: which object a field belongs to, how deep an array goes, where a value is missing.

Sort keys orders object keys alphabetically at every level. It makes two versions of a config file or two API responses easy to compare in a diff, because fields no longer move around.

Worked example

{"user":{"id":42,"roles":["admin","dev"]},"active":true} formats with 2-space indentation as

{
  "user": {
    "id": 42,
    "roles": [
      "admin",
      "dev"
    ]
  },
  "active": true
}

Errors

The most common mistakes are a trailing comma after the last item, single quotes instead of double quotes, comments, and unquoted keys copied from JavaScript. The page names the problem and shows where it is.

How this works

The page parses the text with a strict JSON parser that follows RFC 8259 exactly and records the line and column of the first error, so the message is the same in every browser. Valid input is written back with the indentation you chose; with sorting on, keys are ordered by Unicode code point at every level before writing. Numbers keep JavaScript double precision. The summary counts keys and nesting depth. Everything runs in this tab, so private payloads never leave your machine.

Frequently asked

Does formatting change my data?

No. Only whitespace changes, plus key order if you turn sorting on. Values and types stay the same.

Why is my JSON invalid?

The usual causes are trailing commas, single quotes, comments, unquoted keys and NaN or undefined. The error message names the problem and its line and column.

Can it format JSON with comments (JSONC)?

No. Comments are not part of JSON (RFC 8259) and are reported as errors. Remove them first.

Is my JSON uploaded?

No. Parsing and formatting happen in your browser; nothing is sent or stored.

Sources

Reviewed Oct 17, 2026 · test vectors fixtures/dev/json-formatter/