JSON Formatter & Validator

Paste JSON on the left. It's formatted, validated, or minified on the right — instantly, entirely in your browser.

Updated

Input 0 chars
Output 0 chars

        
Status Waiting for input Keys — Depth — Size —

What it does

This page takes a JSON document, checks that it is valid according to the language's own parser (JSON.parse), and reprints it. Format pretty-prints with a 2-space indent. Minify reprints the same value on one line with no extra whitespace. Both paths parse first, then call JSON.stringify, so the output is a normalized document, not a pretty-print of your original characters.

That distinction matters. If two keys have the same name, the parser keeps the last one. Object key order is preserved. The status strip at the bottom reports whether the input parsed, how many object keys it contains, how deep the nesting goes, and the size of the string that was just written to the output pane.

How to use this page

  1. Paste into the left pane labeled Input. The counter in that pane header tracks character count as you type.
  2. Wait a fraction of a second. The tool does not format on every keystroke. After a short pause it only validates: the status cell reads that the JSON is valid and that you should press Format or Minify, or stays on Typing… while the text is still broken.
  3. Click Format for an indented document, or Minify for a single line. The right pane labeled Output fills in. Status becomes Valid JSON and the Keys, Depth, and Size cells populate.
  4. Click Copy result to put the output pane on the clipboard. The button label flips to Copied for about a second. Nothing happens if the output is empty.
  5. Click Clear to wipe both panes, reset the readout to Waiting for input, and put the cursor back in the input.

If parse fails after you press a button, the output pane is emptied, the status cell turns red, and the message starts with Invalid JSON followed by the parser own wording, including a position when the engine provides one.

Three quick examples

Pretty-print a minified response. Paste this into Input and click Format:

{"ok":true,"items":[{"id":1,"name":"Ada"}]}

Output uses a 2-space indent:

{
  "ok": true,
  "items": [
    {
      "id": 1,
      "name": "Ada"
    }
  ]
}

Readout: Status Valid JSON, Keys 4, Depth 3. Size is the byte length of that pretty string, not of the input.

Minify the pretty version. Leave the pretty document in Input and click Minify. Output is exactly {"ok":true,"items":[{"id":1,"name":"Ada"}]}. Same key and depth counts. Size drops because the spaces and newlines are gone.

A trailing comma, which JSON does not allow. Paste {"a":1,} and click Format. Output stays empty. Status reads an invalid-JSON message pointing at the closing brace after the extra comma (position 7 in typical engines). JSON also rejects single-quoted strings, unquoted keys, and // comments. Those are JavaScript object literals, not JSON.

Worked example: what changed between two webhook versions

A payment provider moves to a new webhook format, and your handler starts failing. Before reading the docs, paste one body of each version and press Format to compare the shape. Version 1:

{"id":"evt_1","type":"order.created","amount":4990,"currency":"brl","customer_id":"cus_8841"}

Readout: Keys 5, Depth 1. Version 2:

{"id":"evt_2","type":"order.created","data":{"amount":4990,"currency":"brl","customer":{"id":"cus_8841"}}}

Format shows the new layout:

{
  "id": "evt_2",
  "type": "order.created",
  "data": {
    "amount": 4990,
    "currency": "brl",
    "customer": {
      "id": "cus_8841"
    }
  }
}

Readout: Keys 7, Depth 3. The values are the same, but amount moved under data, and the customer ID moved two levels down into data.customer.id. Code that reads body.amount now gets undefined. The jump in Depth from 1 to 3 is the quickest signal that fields were nested, before you even scroll through the output. Keys counts the two new wrapper keys, data and customer, which is why it rises from 5 to 7.

What Keys, Depth, and Size measure

Keys is the count of object properties at every level, added together. Array slots are not keys. For {"ok":true,"items":[{"id":1}]} the readout reports 3 keys: ok, items, and id.

Depth is the longest walk from the root. That same document has depth 3: the root object, the items array, then the inner object. A flat object such as {"a":1} has depth 1.

Size is the UTF-8 byte length of the output string, shown in bytes or KB. Formatting and minifying the same value produce different sizes because whitespace is part of the string.

Good moments to reach for it

Use Format when a log line, webhook body, or API response arrives as a single dense line and you need to read it. Use Minify when a hand-edited config has grown extra spaces and you want the smallest legal document to paste into a request body. Use the status strip alone when you only care whether a file is legal JSON before you commit it.

  • Inspecting a minified production payload without opening an editor
  • Confirming a config file has no trailing comma before a deploy
  • Shrinking a fixture so a test snapshot stays one line

Common mistakes

  • Editing the output pane. It is a read-only result, not a second editor. Change the input and run Format or Minify again.
  • Expecting comments or trailing commas to survive. This parser is strict JSON. If you need JSONC or JSON5, strip those extensions first.
  • Pasting two values back to back, such as {}{}. JSON.parse accepts one value only.
  • Assuming the original number spelling is kept. 1.0 and 1 both become 1. Integers above 253 minus 1 lose low bits because they are IEEE-754 doubles.

Limits, and where your JSON goes

It does not sort keys, highlight a syntax tree, convert YAML or XML, or repair broken input. It does not fetch a URL for you. It will not keep formatting live while you type. That is deliberate, so a half-finished edit does not wipe a result you were about to copy.

Parse, stringify, and the clipboard write all run in this tab. The document never leaves your browser. There is no upload and no server-side log of what you paste. Closing the tab drops the text from this page.

Formatting JSON without this page

You can still format or check JSON by hand with the same steps this page automates. Use any editor that can run JSON.parse / JSON.stringify, or a local REPL.

  • Paste the document into a scratch buffer.
  • Parse it (invalid JSON will throw with a position or message).
  • Pretty-print with a 2-space indent, or stringify with no extra whitespace to minify.
  • Fix trailing commas, single quotes, or comments if the parser rejects the text.
  • Copy the normalized output back into your request, config, or fixture.

Example: Input {"a":1,"b":[2,3]} formats to a multi-line object with indented keys; minify collapses it to one line with the same values.

Short answers

Does Format change my data?

Format and Minify both parse then stringify. Valid values are preserved; invalid JSON is rejected. Duplicate keys typically keep the last value.

Why did my trailing comma fail?

Strict JSON does not allow trailing commas, single quotes, or comments. Remove those and try again.

Is my JSON uploaded?

No. Parsing runs in this browser tab. See the Privacy section on this page and the site FAQ.