Json Beautifier

Beautify & format JSON.

Worth a look

Rate this tool

How useful was this tool?

JSON Beautifier

Paste or type JSON into the box, load the Example, or Open a file up to 10 MB (you can also drag it onto the page). It’s formatted as you type.

The output is coloured so the structure is easy to scan: keys, strings, numbers, and true/false/null each have their own colour, in both light and dark themes. Under the output you’ll see the root type, the number of lines, and the size before and after formatting. Copy the result, or Download .json.

Everything runs in your browser. Nothing you paste or open is uploaded.

Example

An API response usually arrives on one line:

{"user":{"id":9007199254740993,"name":"Ana","tags":["admin","editor"],"settings":{},"score":1.50},"items":[{"sku":"A-10","qty":2},{"sku":"A-9","qty":1}]}

Beautified with 2 spaces and Keep short lists on one line switched on:

{
  "user": {
    "id": 9007199254740993,
    "name": "Ana",
    "tags": ["admin", "editor"],
    "settings": {},
    "score": 1.50
  },
  "items": [
    {
      "sku": "A-10",
      "qty": 2
    },
    {
      "sku": "A-9",
      "qty": 1
    }
  ]
}

A few things to notice:

  • Short lists stay on one line. The tags list fits in one line, while items holds objects, so each gets its own block. That’s 19 lines instead of 22.
  • Every value is unchanged. id still has all 16 digits, score is still 1.50, and settings is still an empty object.

Formatting that never changes your data

That second point is less common than it should be. Most online beautifiers read the JSON into JavaScript and print it back out. Run the example above through one of those and you get:

"id": 9007199254740992,
"score": 1.5,

The ID has quietly changed, because JavaScript can’t store whole numbers that large exactly, and 1.50 has lost its zero. Other formatters drop duplicate keys, keeping only the last one. Some turn an empty {} into [], which PHP does when JSON is decoded into arrays.

This beautifier only changes the spacing. Numbers and strings are copied as written, empty objects stay objects, long integers keep every digit, and duplicate keys are all kept. Where something deserves a second look (a duplicate key, an integer too large for JavaScript, or a Windows path whose backslashes may be read as escape codes), you’ll see a note.

Indentation

  • 2 spaces is the most common style for JSON, used by package.json and most web projects.
  • 4 spaces matches many Python projects and is easier to read in deeply nested data.
  • 8 spaces makes each level very clear, at the cost of width.
  • Tabs let everyone who opens the file set their own indent width.
  • One line minifies the JSON. The output label switches to “Minified JSON.” Use it when sending JSON to an API, storing it, or fitting it into a single config value, since it’s the smallest the file can be.

Sort keys A to Z

Sort keys A to Z puts every object’s keys in alphabetical order, nested objects included. Lists keep their order, because the order of items in a list usually means something.

Sorting is natural, so numbers inside keys are compared as numbers:

Natural order (this tool) Plain text order
item1 item1
item2 item10
item10 item2

Sorting is especially useful before comparing two JSON files. Two files with the same data but keys in a different order look completely different until both are sorted. Sort both, then compare them with the Text Diff Checker.

Keep short lists on one line

Lists of plain values (strings, numbers, true/false/null) stay on one line if they fit within 60 characters. Coordinates like [51.5072, -0.1276] or tags like ["admin", "editor"] stay compact instead of spreading over four lines each. Lists containing objects, and longer lists, still get one item per line.

Text escapes

JSON can write any character as an escape code, like u00e9 for é. Text escapes decides what to do with them:

Keep as written leaves every string exactly as it came in.

Show u00e9 as é turns escape codes into the characters they stand for, and / into /. This is the setting for reading PHP output. PHP’s json_encode escapes slashes and non-English letters by default:

{"url":"https://example.com/a","city":"Zu00fcrich"}

With this setting, that becomes "url": "https://example.com/a" and "city": "Zürich".

Write é as u00e9 (ASCII only) does the reverse. Every non-ASCII character becomes an escape code, so the file contains only plain ASCII. Use it for older systems that garble accents or other alphabets. Emoji become two codes each; 😀, for example, is written ud83dude00.

Whichever you choose, quotes, backslashes, control characters and incomplete emoji codes always stay escaped, so the result is always valid JSON.

When the JSON has a mistake

If the input isn’t valid, you get the same help as in the JSON Validator: the line and column, what was found, how to fix it, and an excerpt with a caret under the problem. Show it in the text jumps to the spot. For JSON Lines files and a full list of common mistakes, use the JSON Validator.

Handy details

  • Downloads keep the file name. Open config.json and the download is config.json again, or config.min.json when minified.
  • Ctrl+A (Cmd+A on a Mac) inside the output selects only the output, not the whole page.

FAQ

What’s the difference between the beautifier, the validator and the viewer?

The beautifier formats JSON so it’s easy to read and edit. The JSON Validator focuses on finding and explaining errors, including invisible characters. The JSON Viewer shows JSON as a tree you can expand and collapse.

Does beautifying change my data?

No. Only spaces and line breaks change. Sorting changes the order of keys, and the escape options change how characters are written, but never what they are.

Can I convert JSON to another format?

Yes: JSON to CSV, JSON to YAML and JSON to XML.

Is my JSON uploaded anywhere?

No. Everything happens in your browser, and we never see or store what you paste.

Note: All processing is done client-side. We do not store or see your data.

Contact

Missing something?

Feel free to request missing tools or give some feedback using our contact form.

Contact Us