XML Formatter & Beautifier
Formats an XML string or file with your desired indentation level using a per-element indentation pattern for the best readability.
Option 2: Or upload your XML file
Ctrl + Enter
Result
About the XML formatter
The formatter first checks that your document is well-formed (every tag closed, attributes quoted, a single root element…). If it is not, the exact line and column of the problem is reported. It then re-indents every element on its own line, keeping comments, processing instructions and CDATA sections.
- Normalize: collapses runs of whitespace inside text nodes to a single space and trims them.
- Trim: removes leading and trailing whitespace of text nodes only.
- Trim whitespace: removes text nodes that contain only whitespace and keeps every other text node literally.
- Compact mode: removes all insignificant whitespace, producing a single line (minified XML).