{ } Pretty JSON & XML Try the viewer →

XML Pretty Print — Indent Any XML Online, Free

A wall of XML on a single line, or indented so randomly you can't follow the nesting? Pretty-printing fixes it: one click turns minified or messy XML into clean, evenly indented, readable markup — in your browser, no signup, no upload.

A free online tool · Updated 29 May 2026

What "pretty print XML" actually means

Pretty-printing (also called indenting, formatting, or beautifying) doesn't change what your XML says — it changes how it looks. Elements, attributes, and text stay exactly as they were; the tool just re-flows whitespace so each level of nesting sits one indent deeper than its parent, with each element on its own line.

So this minified blob:

<catalog><book id="1"><title>XML Basics</title><price>29.99</price></book><book id="2"><title>Deep XML</title><price>39.99</price></book></catalog>

becomes this:

<catalog>
  <book id="1">
    <title>XML Basics</title>
    <price>29.99</price>
  </book>
  <book id="2">
    <title>Deep XML</title>
    <price>39.99</price>
  </book>
</catalog>

Now the structure is obvious at a glance: a catalog holding two books, each with a title and a price.

Pretty-print your XML in three steps

1 Paste or upload your XML

Open the viewer and drop your XML into the editor — paste with Ctrl+V (or Cmd+V), or click the upload button to load an .xml file. The editor highlights the syntax as you go, so a stray tag stands out immediately.

2 Click Format

Hit the Format (✨) button in the editor toolbar. The tool parses your XML, walks the element tree, and re-emits it with two-space indentation per level — open and close tags line up, attributes stay on their element, text content sits where it belongs. If the markup is malformed, you get a clear error pointing at the problem instead of garbled output.

3 Copy the clean result

Select the formatted XML and copy it back out — into your editor, a bug report, or a code review. Need it compact again? The Minify (⤴) button does the reverse, stripping indentation back to a single line.

Open the viewer →

Why indentation matters

XML is forgiving about whitespace — a parser reads the minified and indented versions identically. Humans don't. When every tag runs together on one line, you can't tell which </item> closes which <item>, and a missing bracket can hide for hours. Pretty-printing makes the shape of the document visible:

Pretty print vs. minify

Two directions of the same operation. Pretty-printing adds whitespace for humans; minifying removes it for machines and bandwidth. Pretty-print when you're reading, debugging, or diffing; minify when you're about to send the XML over the wire.

Tip: Both buttons auto-detect the format. The same Format and Minify controls work on JSON too — see the companion JSON pretty print page if you're working with both.

Beyond formatting: tree and table views

Indented text is great, but sometimes you want more than clean whitespace. Once your XML is loaded, two extra views are a click away:

So pretty-printing is often just the first step. If your XML is a feed or a list of records, jump straight to the table view and scan it like a spreadsheet.

Open the viewer →

Is my XML uploaded anywhere?

No. The whole tool is a single HTML page with no backend and no upload endpoint. Your XML is parsed and formatted by your browser's built-in engine — it never leaves your machine. That makes it safe for internal configs, API payloads, and anything you wouldn't want on a third-party server.

Quick FAQ

Does pretty-printing change my data?

No. Only whitespace between elements changes. Element names, attributes, text content, and ordering are all preserved — a parser sees the same document before and after.

What indentation does it use?

Two spaces per nesting level, which keeps deep documents from drifting too far to the right while still reading clearly.

Will it format invalid XML?

No — it needs well-formed XML to build the element tree. If a tag is unclosed or mismatched, you'll get an error pointing at the issue.

Can it handle large XML files?

Yes. Formatting runs client-side and the viewer handles 9 MB+ files, using virtual scrolling and lazy tree expansion to stay responsive.

Open the viewer and pretty-print your XML →