XML Formatter
Re-indent XML with consistent spacing and readable nesting, keeping the declaration, DOCTYPE, attribute order, and text content exactly as they were.
How to use
- Paste XML into the input.
- Set the indent width, and turn on collapsing to self-close empty elements.
- Copy the formatted XML.
An XML formatter re-indents a document so each element sits on its own line at a depth that matches its nesting. Nothing in the document changes except whitespace between elements.
Paste or type something above.
Questions about xml formatter
- Is the XML changed in any way?
- Only whitespace between elements. Attribute order, text content, entities, and the declaration stay exactly as they were.
- Why did formatting stop with an error?
- The document is not well-formed XML. XML Validator reports the parser message with the position.
- What does collapsing empty elements do?
- A childless element with no attributes is written as a self-closing tag instead of an open and close pair.
Related tools
- XML Validator Check that XML is well-formed and see the element, attribute, and depth counts, with the p...
- XML to JSON Convert XML into JSON with attributes, text content, and repeated child elements mapped to...
- HTML Formatter Re-indent HTML with consistent indentation and one tag per line, while keeping script, sty...