JSON formatter & beautifier

Pretty-print or minify JSON, sort keys at every level, and turn JSON into an escaped string literal (or back). Numbers keep their exact digits, and nothing leaves your browser.

Mode
Indent
Input
Output
Waiting for inputPaste JSON on the left. The formatted result updates as you type.

How to format JSON

  1. Paste JSON into Input, drop a .json file on it, or click Open file.
  2. Choose a mode. The output updates as you type; copy it or download it as a file.
  3. If the input is not valid, you get the exact line and column of the problem and a Repair it button that opens it in the repair tool.

What each option does

Beautify
Indents with 2 spaces, 4 spaces or tabs, one value per line.
Minify
Removes every unnecessary space and line break. The size panel shows how many bytes you save.
Sort keys
Orders object keys alphabetically at every depth, which makes documents easier to compare. Array order never changes.
Escape
Turns the (minified) JSON into a quoted string literal, ready to embed in code, another JSON document or an environment variable.
Unescape
Does the reverse: paste "{\"a\":1}" and get the JSON back, formatted.

Frequently asked questions

Does formatting change my numbers?

No. JSONMender keeps every number exactly as written, so 1.50 stays 1.50 and 64-bit IDs such as 12345678901234567890 are not rounded, which is what usually happens with JSON.parse and JSON.stringify.

What happens to duplicate keys?

They are kept in place. Sorting keys keeps duplicates next to each other in their original order; the JSON validator can list them for you.

Is 2 or 4 space indentation better?

Both are valid JSON. Two spaces is the most common choice in JavaScript projects and keeps deep documents narrow; four spaces is common in Python projects. Tabs let every reader choose their own width.