Skip to content

XML Formatter & Beautifier

This XML formatter re-indents XML, shows it as a tree and points to syntax errors by line and column. It runs entirely in your browser.

Input · XML
<rss> 2 children
@version: "2.0"
<channel> 5 children
<title>: Release notes
<link>: https://example.com/changelog
<description>: What shipped this week
<item> 3 children
<title>: Dark mode for reports
<pubDate>: Mon, 03 Nov 2026 09:00:00 GMT
<category>: UI
<item> 3 children
<title>: Faster CSV export
<pubDate>: Tue, 04 Nov 2026 14:30:00 GMT
<category>: Performance
Valid XMLroot <rss> · 13 elements · depth 4Runs in your browser

Load from a URL

Your browser fetches it directly, so the server must allow cross-origin requests (CORS).

How to format XML

  1. Paste XML, drop a file, or use From URL.
  2. Press Format (Ctrl + Enter) and pick an Indent: 2 spaces, 4 spaces or tabs.
  3. Minify (Ctrl + Shift + M) puts it back on one line. XML minify can also keep comments.

Example: a one-line SOAP response

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetQuoteResponse><Symbol>ACME</Symbol><Price>41.27</Price><Warnings></Warnings><!-- cached 60 s --><Note><![CDATA[Delayed 15 min & indicative]]></Note><Summary>Closed <b>up</b> 2%</Summary></GetQuoteResponse></soap:Body></soap:Envelope>

Formatted with 2 spaces:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetQuoteResponse>
      <Symbol>ACME</Symbol>
      <Price>41.27</Price>
      <Warnings></Warnings>
      <!-- cached 60 s -->
      <Note><![CDATA[Delayed 15 min & indicative]]></Note>
      <Summary>Closed <b>up</b> 2%</Summary>
    </GetQuoteResponse>
  </soap:Body>
</soap:Envelope>

The comment and the CDATA section stay in place. <Summary> mixes text and a tag, so it stays on one line: a line break inside it would change the text. Self-close empty tags turns <Warnings></Warnings> into <Warnings/>.

What the XML formatter keeps

Only the whitespace between tags changes. Text inside elements is never trimmed or rewrapped, and the declaration, DOCTYPE, processing instructions, namespace prefixes, attribute order and quotes stay as written. Self-closing tags stay self-closing.

Errors and the tree view

Format needs well-formed XML. An unclosed tag or a bare & stops it, and the Report tab shows the line, column and a fix, with Go to error to jump there. The XML validator lists the common messages.

While the XML is valid, the status bar shows the root element, element count and depth, and the Tree tab gives a searchable outline. Select a node to copy its XPath for the XPath tester, or turn the document into JSON with XML to JSON.

Questions

Is an XML beautifier different from an XML formatter?

No. Beautify, prettify and pretty print all mean re-indenting XML so each element starts on its own line.

Does it reorder elements or attributes?

No. Elements, attributes and namespace declarations keep their order and their quotes.

Can it format HTML?

Only XHTML, or HTML that is also well-formed XML. A line break tag without its closing slash, or an unquoted attribute, fails the check.

Is my XML uploaded?

No. It is formatted in this tab, and there is no save or share feature. The last XML you pasted stays in local storage so the other XML tools can open it; Clear removes it.

Related tools

Esc