JSON Formatter & Validator
Paste JSON on the left. It's formatted, validated, or minified on the right, entirely in your browser.
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. Most non-integer keys retain their order. JavaScript moves integer-like keys to the front in numeric order, so the output is not guaranteed to keep the original key sequence. 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
- Paste into the left pane labeled
Input. The counter in that pane header tracks character count as you type. - 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. - Click
Formatfor an indented document, orMinifyfor a single line. The right pane labeledOutputfills in. Status becomesValid JSONand the Keys, Depth, and Size cells populate. - Click
Copy resultto put the output pane on the clipboard. The button label flips toCopiedfor about a second. Nothing happens if the output is empty. - Click
Clearto wipe both panes, reset the readout toWaiting 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.parseaccepts one value only. - Assuming the original number spelling is kept.
1.0and1both become1. Integers above 253 minus 1 lose low bits because they are IEEE-754 doubles.
Before formatting an ID or a signed payload
Whitespace is not the only thing that can change when JavaScript parses and serializes JSON. Try {"order_id":9007199254740993}. The formatted result contains "order_id": 9007199254740992, because that integer is outside the range JavaScript represents exactly. Keep identifiers like this as strings in the source data if every digit matters.
Duplicate keys also collapse to the last value, 1.0 becomes 1, and decoding an escaped character can change its source spelling, for example \u00e9 to é. Those are reasons to keep the untouched original when checking a signature, comparing raw request bytes or investigating a duplicate-key disagreement.
The pretty-print JSON guide shows these changes with inputs and outputs, plus local command-line options for files that belong in an editor or CI job.
Limits, and where your JSON goes
It does not let you choose an indentation width, deliberately 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.
JSON formatting questions
How do I pretty print JSON here?
Paste one JSON value, then click Format. The tool parses it and writes it with 2-space indentation. Click Minify instead when you want the same parsed value without extra whitespace.
Does formatting preserve every character and numeric value?
No. It normalizes the parsed document. Duplicate keys keep their last value, very large integers can lose digits, number spelling can change and character escapes can be decoded. Keep the original for byte-level comparisons or signatures.
Why did my trailing comma fail?
Strict JSON does not allow trailing commas, single-quoted strings, comments or unquoted keys. Fix the syntax and format again; the tool does not silently repair it.
Can it validate required fields or sort keys?
No. It validates JSON syntax, not a schema. It does not offer a sort-keys option, and integer-like keys may be reordered by JavaScript. Use a schema validator for required fields and types.
Is my JSON uploaded?
No. Parsing, formatting and minification run locally in this tab. Fieldkit does not receive your document for processing.