JSON formatter

Paste JSON to pretty-print it, check it's valid, or squeeze it onto one line. If something's wrong you get the exact line and column and a plain explanation of the fix.

  • 100% free
  • Runs in your browser
  • No uploads
Indent

Escape or unescape a string

How to format and validate JSON

  1. Paste your JSON. With Format as I type on, it's checked and formatted a moment after you stop typing.
  2. Pick the indent. Two spaces, four spaces or tabs. Tick Sort keys to order object keys alphabetically.
  3. Fix any error. The error panel shows the line, the column and what to change. Go to the error selects that spot in your text.
  4. Copy or download. Copy the result or save it as a .json file. Minify puts everything on one line for sending or storing.

Common JSON errors and how to fix them

ErrorWrongRight
Trailing comma[1, 2, 3,][1, 2, 3]
Single quotes{'name': 'Ada'}{"name": "Ada"}
Unquoted key{name: 1}{"name": 1}
Missing comma{"a": 1 "b": 2}{"a": 1, "b": 2}
Python values{"ok": True, "x": None}{"ok": true, "x": null}
Line break inside a string"two
lines"
"two\nlines"
Leading zero{"zip": 02134}{"zip": "02134"}

What this formatter does differently

Your values are never rewritten. Numbers keep their exact digits (no rounding of large IDs, no dropping of trailing zeros) and strings keep their escapes, so \u00e9 stays \u00e9. The output means exactly what the input meant.

Errors are explained, not just reported. Browsers' own JSON errors differ, and Safari's don't include a position at all. This tool uses its own strict parser, so you get the same precise line and column in every browser.

Duplicate keys are flagged. JSON allows the same key twice in one object, but most programs silently keep only the last one. If your file has a duplicate, you'll see a warning with its line number.

Frequently asked questions

Is my JSON sent to a server?

No. Formatting and validation run in your browser, in a background worker so large files don't freeze the page. Nothing is uploaded, which makes it safe for API responses, config files and data that contains personal details or keys.

Why do other formatters change my numbers?

Most online formatters run JSON.parse and JSON.stringify, which turn every number into a JavaScript double. A 19-digit ID like 12345678901234567890 comes back as 12345678901234567000, and 1.50 becomes 1.5. This formatter keeps every number and string exactly as you wrote it; only spaces, line breaks and, if you ask, key order change.

Does it accept comments or trailing commas?

No, because standard JSON doesn't allow them and most programs will reject a file that has them. The validator points to the exact spot and says what to change. Files like tsconfig.json or VS Code settings use a looser format called JSONC, which does allow comments.

What does Sort keys do?

It orders the keys of every object alphabetically, at every level, without touching the order of items in arrays. That makes two versions of the same data much easier to compare in a diff. Keys are compared by their character codes, so capital letters sort before lower-case ones.

How large a file can it handle?

Files of several megabytes format in about a second on a typical laptop. Above 1 MB the tool waits for you to press Format instead of formatting as you type, so pasting stays smooth. Very large files (tens of megabytes) depend on your device's memory.

Learn more