JSON Beautifier

Format, minify and validate JSON in your browser: 2/4-space or tab indent, recursive key sorting, exact big numbers, open and save .json files.

Your inputs and files stay in your browser

Input JSON

Paste JSON or drop a .json file here to format, minify or sort its keys.

In the editor, Tab indents. Press Esc, then Tab to move focus out.

On this page

Paste or open a JSON document and turn it into readable, consistently indented text — or minify it back to a single line. The editor highlights syntax, folds objects and arrays and shows the parser's error position, without sending your data anywhere.

Detailed Functionality

Format rewrites the document with 2 spaces, 4 spaces or a tab per level, and Compact mode (minify) removes every insignificant space and line break. Sort keys orders the keys of every object, at all nesting levels, which makes two JSON files easy to compare in a diff. Numbers are written exactly as in the source — 12345678901234567890 and 1.0 are not rounded or shortened — in browsers that support JSON.rawJSON (current Chrome, Edge and Firefox).

Input is checked by the browser's strict JSON parser: comments, trailing commas and single quotes are rejected, and the message points to the problem, e.g. Expected double-quoted property name in JSON at position 7 (line 1 column 8) in Chrome. The editor stays responsive on multi-megabyte files, including minified JSON on one line, and Ctrl/Cmd+F searches inside it.

Open a .json file or drop it onto the editor, then copy the result or download it as formatted.json. The indent, sorting and compact settings are remembered in this browser; the JSON text itself is never stored or uploaded.

Practical Examples

Minify a response: with Compact mode on, { "a": [1, 2], "b": "x" } spread over several lines becomes {"a":[1,2],"b":"x"}.

Sort keys at every level: {"b":1,"a":{"d":true,"c":[1,2]}} with Sort keys and Compact mode gives {"a":{"c":[1,2],"d":true},"b":1}.

Keep big IDs intact: {"id": 12345678901234567890, "price": 1.0} is minified to {"id":12345678901234567890,"price":1.0}; a plain JSON.parse + JSON.stringify round trip would turn the ID into 12345678901234567000 and the price into 1.

Find a syntax error: {"a":1,} is not formatted; the error names position 7 (line 1, column 8) — the trailing comma before }.

How to Use This Tool

  1. Add your JSON

    Paste the text into the Input JSON editor, click Open to load a .json file, or drop the file onto the editor.

  2. Choose the formatting

    Pick the Indent size (2 spaces, 4 spaces or Tab) and, if needed, enable Sort keys or Compact mode (minify).

  3. Format

    Click Format or press Ctrl+Enter (Cmd+Enter on macOS). Invalid JSON is reported above the editor and your text is left unchanged.

  4. Use the result

    Click Copy to put the result on the clipboard or Download to save it as formatted.json.

Tips and Best Practices

  • Changing the indent, Sort keys or Compact mode re-formats the current text right away.
  • JSON5-style input (comments, trailing commas, single quotes, unquoted keys) is not valid JSON — the parser stops at the first such character.
  • Sort keys uses plain character order, so "B" comes before "a", and integer-like keys such as "2" and "10" always come first (a JavaScript object rule).
  • Click the arrows next to the line numbers to fold large objects and arrays; Ctrl/Cmd+F finds text even in lines scrolled out of view.
  • In the editor Tab inserts indentation; press Esc, then Tab to move focus out.
  • After the first visit the page also works offline, and the JSON never leaves your browser.