Beautify JSON: format, validate, and minify in one pass
A JSON formatter takes JSON that has been minified, hand-edited, or pasted from a log and rewrites it as a readable, evenly indented tree. The input is parsed with the browser native JSON.parse, so the document must be valid JSON: double-quoted keys and strings, no trailing commas, no comments. If parsing succeeds, the value is re-serialized with JSON.stringify at the indent width you choose. If it fails, the output panel shows the engine parse error with the position of the first problem so you can fix the source.
Indentation has four modes. Two spaces is the default and the most common style for config files and API payloads. Four spaces suits codebases that indent that way. Tabs emit a single tab character per nesting level. Minify drops all insignificant whitespace and returns the document on one line, which is what you want for transport or for shrinking a payload before pasting it somewhere with a size limit.
Sort keys reorders the keys of every object alphabetically, descending into nested objects and through arrays of objects. Two JSON documents that carry the same data in a different key order produce identical output once sorted, which makes a sorted format the fast way to diff two payloads or canonicalize a config before committing it. Array element order is never touched, since order is meaningful in a JSON array.
Everything runs client-side, so large payloads stay on your machine and nothing is logged. For format conversions rather than reformatting, see JSON to YAML, JSON to CSV, or CSV to JSON.
How to use json formatter
- 1Paste or type your JSON into the input panel on the left.
- 2Pick an indent width: 2 spaces, 4 spaces, tabs, or minify.
- 3Toggle Sort keys if you want every object key ordered alphabetically.
- 4Read the formatted JSON in the output panel, or the parse error if the input is invalid.
- 5Click Copy or Download to save the result as a
.jsonfile.
Keyboard shortcuts
Drive TextResult without touching the mouse.
| Shortcut | Action |
|---|---|
| Ctrl F | Open the find & replace panel inside the input Plus |
| Ctrl Z | Undo the last input change |
| Ctrl Shift Z | Redo |
| Ctrl Shift Enter | Toggle fullscreen focus on the editor Plus |
| Esc | Close find & replace, or exit fullscreen |
| Ctrl K | Open the command palette to jump to any tool Plus |
| Ctrl S | Save current workflow draft Plus |
| Ctrl P | Run a saved workflow Plus |
What this tool actually does
Strict JSON parse via the browser engine
The input is parsed with JSON.parse, so trailing commas, single-quoted strings, comments, unquoted keys, and NaN or Infinity literals are rejected. The engine error message, including the character offset of the first fault, is shown in the output panel.
Four indent modes
Two spaces (default), four spaces, and tabs each emit block-style indentation one level per nesting depth. Minify passes 0 as the indent, which removes every insignificant space and newline and returns the whole document on one line.
Recursive alphabetical key sort
With Sort keys on, every object key set is reordered with a plain code-unit string sort, descending into nested objects and into objects inside arrays. Array element order is left exactly as written, since position carries meaning in an array.
Values round-trip unchanged
Strings, numbers, booleans, and null are re-emitted as JSON.stringify writes them. Numbers parse as IEEE-754 doubles, so integers beyond 2^53 may lose low digits at parse time; store those as strings if you need exact round-trips.
Runs entirely in your browser
No upload, no server round trip, no log of what you pasted. Each keystroke or option change reparses and reformats the current input. Documents up to a few megabytes reformat without leaving your machine.
Worked example
The minified object is reparsed and printed with two-space indentation. Keys stay in their original order because Sort keys is off by default, and the array expands one item per line.
{"name":"textresult","tags":["text","tools"],"public":true,"count":42,"owner":null}
{
"name": "textresult",
"tags": [
"text",
"tools"
],
"public": true,
"count": 42,
"owner": null
}
Settings reference
| Setting | Effect on output |
|---|---|
| Indent: 2 spaces | Default. Two spaces per nesting level, block style. |
| Indent: 4 spaces | Four spaces per nesting level. |
| Indent: Tabs | One tab character per nesting level. |
| Indent: Minify | All insignificant whitespace removed; output on a single line. |
| Sort keys | Off by default. On reorders every object key alphabetically, recursively. Array order is never changed. |
| JSON parse | Strict JSON.parse. Trailing commas, comments, single quotes and unquoted keys are rejected. |
| Invalid JSON | The parser message and fault position are shown in the output; no partial JSON is emitted. |
| Empty input | Output stays blank until you paste valid JSON. |
FAQ
Does it validate my JSON?
JSON.parse before printing anything. If the document is valid you get the formatted result; if not, the output panel shows the exact parse error and where it occurred, so the tool doubles as a JSON validator.How do I minify instead of beautify?
Will sorting keys change my data?
Why does it reject my JSON with trailing commas?
JSON.parse follows the JSON spec, which does not allow trailing commas, comments, or single-quoted strings. Those are JavaScript object syntax, not JSON. Remove the trailing comma or comment and the formatter will accept it.