Developer Tools · Formatters
XML formatter.
Paste XML to pretty-print it with the indent you choose. Attribute order, CDATA, comments and the XML declaration stay as written. If the XML is not well-formed you get the line and column of the first error.
Your XML
Result
Paste XML and press Format XML.
What the formatter changes
Formatting only changes white space between elements: each child element goes on its own line, indented by depth. Tags are copied character for character, so attribute order, quoting, CDATA sections, comments, processing instructions, the XML declaration and any DOCTYPE are unchanged. Elements that hold only text stay on one line.
Warning: white space can be data
In XML, white space inside an element can be meaningful. The XML 1.0 specification (section 2.10) says applications may treat it as significant and defines the xml:space="preserve" attribute to ask for that. So this tool leaves an element exactly as written when it mixes text with child elements (for example <p>Hi <b>there</b></p>) or is marked xml:space="preserve", and it lists those elements in the result. Even elsewhere, if your application reads the white space between elements, check the output before you rely on it.
Minify and limits
Minify is a secondary option: it removes white space between elements and removes comments, again leaving mixed content and preserved elements alone. The formatter runs only on well-formed input, checked with your browser's built-in XML parser (DOMParser). That is a well-formedness check, not validation against an XSD or DTD. Error wording and position can differ between Chrome, Firefox and Safari, and only the first error is reported. To check a document without reformatting it, use the XML validator.
Sources: W3C, Extensible Markup Language (XML) 1.0, section 2.1 (well-formed documents) and section 2.10 (white space handling); MDN, DOMParser. Everything runs in your browser. Nothing you paste is stored or sent.