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.
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:
- See nesting depth — child elements step in, siblings line up, so the hierarchy reads top to bottom.
- Spot mismatched tags — an opening tag with no matching close jumps out once everything is aligned.
- Diff two documents — formatted XML produces clean, line-by-line diffs instead of one giant changed line.
- Read API responses — SOAP envelopes, RSS feeds, and config files arrive minified; indenting makes them reviewable.
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.
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:
- Tree view renders the document as foldable nodes, so you can collapse branches and focus on one subtree — handy for deeply nested SOAP responses.
- Table view detects repeated elements — RSS
<item>tags, product entries, record rows — and lays them out as a sortable, searchable table with shared tags as columns.
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.
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.