JSON Formatter

Pretty-print JSON for reading, minify it for sending, or sort keys for a stable diff. Errors point to the exact line and column.

Runs in your browser

JSON

Formatted JSON

Numbers are kept exactly as written. Nothing is uploaded.

How to use the JSON Formatter

  1. Paste JSON into the editor, open a .json file, or press Sample.
  2. Press Format (Ctrl + Enter) to indent it, or Minify to remove whitespace.
  3. Turn on Sort keys to order object keys alphabetically.
  4. Copy the result or download it as a .json file.

Example

Format a compact API response
Input
{"id":1842,"user":{"name":"Ada","roles":["admin","editor"]},"active":true,"balance":12345678901234567890}
Result
{
  "id": 1842,
  "user": {
    "name": "Ada",
    "roles": [
      "admin",
      "editor"
    ]
  },
  "active": true,
  "balance": 12345678901234567890
}

The large number is kept exactly. Many formatters that use JSON.parse would round it to 12345678901234567000.

What it does

Lossless formatting
Numbers are printed exactly as you wrote them, so IDs and amounts larger than JavaScript can represent are never rounded.
Clear error messages
Trailing commas, single quotes, unquoted keys and missing brackets are explained in plain English with a line and column.
Sort, indent, minify
2 or 4 spaces, tabs or minified output, with optional alphabetical key sorting.
Private
API responses often contain tokens and personal data. Everything stays in your browser.

Frequently asked questions

Why does my JSON show an error?

The most common causes are a trailing comma after the last item, single quotes instead of double quotes, keys without quotes, and comments. JSON allows none of these. The error message tells you which one and where.

Does it change my data?

No. Only whitespace changes, plus key order if you turn on Sort keys. Strings, escapes and numbers are kept character for character.

How large a file can I format?

Files of several megabytes format in well under a second on a typical laptop. Very large files are limited by your device memory rather than by the tool.

Can it fix invalid JSON automatically?

Not yet. It shows exactly where the problem is so you can fix it yourself without guessing what was intended.