How to format XML
- Paste XML, drop a file, or use From URL.
- Press Format (Ctrl + Enter) and pick an Indent: 2 spaces, 4 spaces or tabs.
- 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.