Private JSON Formatter & Validator

For the single-line API response, webhook body or log dump you need to read now, often with customer data or a bearer token in it. JSON is indented in your browser, with errors pinned to a line and column and 64-bit IDs left exactly as written.

Input

Settings

History

Load from URL

What this JSON formatter does

This page re-indents JSON, validates it against the strict RFC 8259 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, which is often the fastest way to scan a list endpoint’s response.

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.

Options

  • Inline short arrays keeps arrays of plain values on one line when they fit the line width, so "Action": ["s3:GetObject", "s3:ListBucket"] stays compact in an IAM policy 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; 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. Two API responses become easy to compare, 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.

Matching the error your runtime printed

Parsers report the same mistakes in very different words. These are the usual translations:

  • Unexpected token '<', "<!DOCTYPE "... is not valid JSON in Chrome and Node means the response was an HTML page. Older versions say Unexpected token < in JSON at position 0. Check the status code before the parser.
  • JSONDecodeError: Expecting value: line 1 column 1 (char 0) in Python usually means an empty body or HTML, not malformed JSON.
  • Expecting property name enclosed in double quotes means single-quoted keys or a trailing comma, typically from print(dict) instead of json.dumps.
  • Unexpected end of JSON input means the text was cut off, often by a log line limit.

Paste the same text here and the message names the actual character and line.

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

Failed-payment webhook 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

AWS IAM policy with compact action lists

Action and Resource lists stay on one line each while Statement and Condition expand, which is how most people review a policy.

Input
{"Version":"2012-10-17","Statement":[{"Sid":"ReadReports","Effect":"Allow","Action":["s3:GetObject","s3:ListBucket"],"Resource":["arn:aws:s3:::acme-reports","arn:aws:s3:::acme-reports/*"],"Condition":{"Bool":{"aws:SecureTransport":"true"},"StringEquals":{"aws:PrincipalTag/team":"finance"}}}]}
Output
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ReadReports",
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:ListBucket"],
      "Resource": ["arn:aws:s3:::acme-reports", "arn:aws:s3:::acme-reports/*"],
      "Condition": {
        "Bool": {
          "aws:SecureTransport": "true"
        },
        "StringEquals": {
          "aws:PrincipalTag/team": "finance"
        }
      }
    }
  ]
}
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.

Why do I get Unexpected token < in JSON at position 0?

Your code tried to parse an HTML page, usually a 404, a login redirect or a proxy error. Log the response status and body first; there is nothing wrong with the parser.

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 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