JSON Formatter and Validator

Paste minified or broken JSON and get indented, validated output with errors pinned to the exact line. Large API responses, log dumps and config files all work.

Input

Settings

History

Load from URL

What this JSON formatter does

JSON (RFC 8259) is the default wire format for REST APIs, webhooks, package.json, AWS policies and most structured logs. When it arrives as one long line it is unreadable, and when it is broken the usual parser error (“Unexpected token } in JSON at position 4021”) tells you almost nothing.

This page re-indents JSON, validates it against the strict grammar, and minifies it again when you need a compact payload. Besides the code view there is a Tree view for collapsing deep objects and a Table view that turns an array of records into sortable columns you can export to CSV or Excel.

How to use it

  1. Paste JSON into the left pane, or drop a .json, .geojson or .har file on it. Auto-detection switches to JSON when the text parses as JSON.
  2. Press Ctrl/Cmd+Enter to format. Output appears on the right with any problems listed underneath; click one to jump to its line.
  3. Press Ctrl/Cmd+Shift+M for minified output and Ctrl/Cmd+Shift+C to copy the result. Ctrl/Cmd+K opens the command palette for everything else, such as switching views or running a JSONPath query.

The work happens in a Web Worker on your machine. Nothing is sent to a server, which matters when the payload contains customer records or a bearer token.

Options

  • Inline short arrays keeps arrays of plain values on one line when they fit the line width, so "tags": ["priority", "gift"] stays compact instead of taking four lines. Arrays containing objects are always expanded.
  • Escape non-ASCII writes every character outside ASCII as a \uXXXX escape. Use it when the receiving system mangles UTF-8, for example an old Java properties pipeline; the data itself does not change.
  • Indent (2 spaces, 4 spaces or tabs) and line width control layout.
  • Sort keys orders object keys alphabetically at every level. That makes two API responses easy to diff, but keep it off when key order is meaningful to a human reader.

Edge cases handled carefully

Integers above 2^53. JavaScript’s JSON.parse silently rounds 9007199254740993 to 9007199254740992. Database IDs, Twitter/X snowflake IDs and ledger amounts hit this. The formatter never converts numbers to floating point: it copies the digits exactly as written, including 1.50 and 1e3. See big integers in JSON for the background.

Duplicate keys. {"a":1,"a":2} is technically allowed by the spec, but most parsers keep only the last value. The tool formats it and raises a warning on the second key so the conflict is visible.

Byte-order mark. Files saved by Notepad or exported from Windows tools often start with a UTF-8 BOM, which makes JSON.parse fail at position 0. The BOM is removed and an info note says so.

Very large files. Formatting streams through the document with constant memory, so a 100 MB export works. Sorting keys needs the whole tree in memory, so it is slower on huge inputs.

When the input is almost JSON

Payloads copied out of JavaScript, Python or a log line often contain trailing commas, single quotes, True/None, NaN or comments. The error message names the exact problem, and Fix it repairs these cases and shows a line diff of every change before you accept it. If the comments are intentional (a tsconfig.json or VS Code settings file), use the JSON5 / JSONC formatter instead. If you have one JSON object per line, use the JSON Lines formatter.

Examples

Minified order from an e-commerce API

A typical single-line API response becomes a readable nested document with two-space indentation.

Input
{"id":"ord_7Q2xN","status":"paid","placedAt":"2026-09-14T08:21:05Z","customer":{"id":"cus_4410","name":"Aisha Tan","email":"[email protected]"},"lines":[{"sku":"KB-104","name":"Mechanical keyboard","qty":1,"unitPrice":129.9},{"sku":"MS-220","name":"Wireless mouse","qty":2,"unitPrice":39.5}],"shipping":{"method":"express","address":{"line1":"18 Marina Blvd","city":"Singapore","postcode":"018980"}},"total":208.9}
Output
{
  "id": "ord_7Q2xN",
  "status": "paid",
  "placedAt": "2026-09-14T08:21:05Z",
  "customer": {
    "id": "cus_4410",
    "name": "Aisha Tan",
    "email": "[email protected]"
  },
  "lines": [
    {
      "sku": "KB-104",
      "name": "Mechanical keyboard",
      "qty": 1,
      "unitPrice": 129.9
    },
    {
      "sku": "MS-220",
      "name": "Wireless mouse",
      "qty": 2,
      "unitPrice": 39.5
    }
  ],
  "shipping": {
    "method": "express",
    "address": {
      "line1": "18 Marina Blvd",
      "city": "Singapore",
      "postcode": "018980"
    }
  },
  "total": 208.9
}
Open this example in the tool

Webhook payload with keys sorted for diffing

Sorting keys puts two webhook deliveries in the same order, so a text diff shows only the fields that really changed.

Input
{"type":"invoice.payment_failed","created":1789475200,"livemode":false,"data":{"object":{"customer":"cus_4410","attempt_count":3,"amount_due":4900,"currency":"usd","next_payment_attempt":1789561600,"billing_reason":"subscription_cycle"}},"id":"evt_1PqR8s"}
Output
{
  "created": 1789475200,
  "data": {
    "object": {
      "amount_due": 4900,
      "attempt_count": 3,
      "billing_reason": "subscription_cycle",
      "currency": "usd",
      "customer": "cus_4410",
      "next_payment_attempt": 1789561600
    }
  },
  "id": "evt_1PqR8s",
  "livemode": false,
  "type": "invoice.payment_failed"
}
Open this example in the tool

Snowflake IDs that must not lose precision

The 19-digit IDs keep every digit, and the short metrics arrays stay on one line.

Input
{"tweets":[{"id":1834219047812235265,"author_id":44196397,"metrics":[512,88,1203]},{"id":1834219047812235266,"author_id":783214,"metrics":[3,0,41]}],"next_token":"7140dibdnow9c7btw4b0"}
Output
{
  "tweets": [
    {
      "id": 1834219047812235265,
      "author_id": 44196397,
      "metrics": [512, 88, 1203]
    },
    {
      "id": 1834219047812235266,
      "author_id": 783214,
      "metrics": [3, 0, 41]
    }
  ],
  "next_token": "7140dibdnow9c7btw4b0"
}
Open this example in the tool

Non-ASCII names escaped for a legacy consumer

Accented and CJK characters become \uXXXX escapes, which decode to the same strings in any JSON parser.

Input
{"customers":[{"name":"Zoë Müller","city":"Zürich"},{"name":"王芳","city":"上海"},{"name":"José Álvarez","city":"São Paulo"}]}
Output
{
  "customers": [
    {
      "name": "Zo\u00eb M\u00fcller",
      "city": "Z\u00fcrich"
    },
    {
      "name": "\u738b\u82b3",
      "city": "\u4e0a\u6d77"
    },
    {
      "name": "Jos\u00e9 \u00c1lvarez",
      "city": "S\u00e3o Paulo"
    }
  ]
}
Open this example in the tool

Common errors and how to fix them

ErrorCauseFix
Trailing comma before '}'
Explained
A comma follows the last property or array item, which JavaScript allows but JSON does not.Delete the comma after the last entry, or press Fix it to remove every trailing comma at once.
Object keys must use double quotes, not single quotes
Explained
The text was copied from JavaScript or Python source, where {‘id’: 1} is valid but JSON requires “id”.Replace the single quotes around keys and strings with double quotes; Fix it does this safely, even for strings that contain apostrophes.
Unexpected end of input: 1 bracket is still open — '{' opened at line 1
Explained
The document was cut off, usually by a log line limit, a terminal scrollback buffer or a partial copy.Copy the complete response again. If the tail is lost for good, Fix it closes the open brackets so you can at least read what arrived.
Unexpected '<' where a value was expected
Explained
The server returned an HTML page (often a 404, a login redirect or a proxy error) instead of JSON.Look at the HTTP status and response body of the request; the problem is on the server or in the URL, not in your JSON handling.
'True' is a Python literal, not JSON
Explained
A Python dict was printed with print() or str() instead of json.dumps(), so True, False and None appear where JSON needs true, false and null.Serialize with json.dumps(data) on the Python side, or use Fix it to convert the literals here.
Missing comma after line 12
Explained
Two properties or array items sit next to each other with nothing between them, often after a hand edit.Add a comma at the end of the line the message names.

Frequently asked questions

Is my JSON uploaded anywhere?

No. Parsing and formatting run in your browser tab. Share links put the data in the URL fragment, which browsers never send to a server, and a secret scanner warns you before you share text that looks like a key or token.

How do I format JSON in VS Code?

Open the file and run Format Document: Shift+Alt+F on Windows, Shift+Option+F on macOS, Ctrl+Shift+I on Linux. For an unsaved snippet, set the language mode to JSON first. This page is quicker for one-off payloads and also shows a tree and table view.

Why does a long ID change when I format it in other tools?

Most JavaScript-based formatters run JSON.parse, which stores numbers as 64-bit floats and rounds integers above 9,007,199,254,740,991. This formatter keeps the original digits, so IDs and amounts come out exactly as they went in.

Can JSON contain comments?

Standard JSON cannot. Files like tsconfig.json and VS Code settings use JSONC, a variant that allows comments and trailing commas; format those with the JSON5 / JSONC formatter so the comments are kept.

How large a file can I format?

Files of 100 MB and more work because the formatter streams through the text instead of building the full object in memory. The practical limit is your browser tab’s memory; the Tree and Table views and Sort keys need more of it than plain formatting.

How do I pretty-print JSON on the command line?

Use jq . file.json or python -m json.tool file.json. Python keeps big integers intact but rewrites floats such as 1.50 as 1.5; jq 1.7 and later preserve large integer literals.

Related tools