XML Formatter
Pretty print XML documents so nested elements are easy to read. Attributes, comments, CDATA sections, and the XML declaration are preserved, and empty elements stay as self closing tags. Everything runs in your browser, nothing is uploaded.
Input
Output
Formatted output will appear hereReady. Press Format or Minify.
How to use the XML Formatter
- Paste XML into the input pane.
- Pick an indent: 2 spaces, 4 spaces, or tabs.
- Press Format and copy the output.
Example
The compact catalog becomes nested, indented XML.
<catalog><book id="1"><title>JSON Basics</title><author>Ada</author><empty/><price>9.99</price></book><book id="2"><title>XML Guide</title></book></catalog>
Frequently asked questions
Are attributes preserved?
Yes. Attributes stay on their elements, and empty elements render as self closing tags like <empty/>.
What about the XML declaration?
It is preserved when present, and never added when absent. Comments and CDATA sections are kept too.
Does formatting change my data?
Element names, attributes, and text are unchanged. Only whitespace between elements is normalized. Documents that mix text with child elements may see the spacing around inline text shift, and the tool warns you when that happens.