JSON Formatter

Paste raw or minified JSON into the JSON formatter and get a clean, validated, indented document back. It parses your input with the browser native JSON.parse, then re-serializes with the indentation you pick: 2 spaces, 4 spaces, tabs, or minified to a single line. Turn on Sort keys to reorder every object key alphabetically, recursively through nested objects. The parse and format run in your browser; nothing uploads.

Input
Line 1:1 LF
Result JSON Formatter
0 lines 0 chars

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

  1. 1Paste or type your JSON into the input panel on the left.
  2. 2Pick an indent width: 2 spaces, 4 spaces, tabs, or minify.
  3. 3Toggle Sort keys if you want every object key ordered alphabetically.
  4. 4Read the formatted JSON in the output panel, or the parse error if the input is invalid.
  5. 5Click Copy or Download to save the result as a .json file.

Keyboard shortcuts

Drive TextResult without touching the mouse.

Shortcut Action
Ctrl FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun 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.

Input
{"name":"textresult","tags":["text","tools"],"public":true,"count":42,"owner":null}
Output
{
  "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?
Yes. The formatter parses the input with 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?
Set the Indent option to Minify. The document is reparsed and returned on a single line with all insignificant whitespace removed, which is the smallest valid form of the same data.
Will sorting keys change my data?
No. Sorting only reorders the keys inside objects; the values stay identical and array element order is never touched. Sorted output is useful for diffing two payloads that hold the same data in a different key order.
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.
Is my JSON sent to a server?
No. Parsing and formatting run entirely in your browser as JavaScript. Nothing is uploaded, nothing is logged, and no copy of your JSON exists on our servers.