📐 XML Formatter & Minifier
Paste XML to beautify it with indentation or minify it to a single line. This is a separate tool from the HTML Formatter, tuned for XML's stricter self-closing and nesting rules.
Check first, then reshape
Whatever the mode, the input is parsed by the browser's own
DOMParser and rejected if it produces a parser error, so malformed
nesting is caught before anything is rewritten. Minify then does one thing -
delete whitespace that sits between two tags:
> < becomes ><
Beautify starts from that minified string, splits it into tags and text runs,
and gives each its own line with two spaces per level. Opening tags increase the
depth, closing tags decrease it, and self-closing tags, comments and the
<?xml?> declaration sit at the current level. Text lands on its
own line too, so <title>Learning XML</title> comes back
as three lines rather than one.
What survives and what does not
- Whitespace inside an element is data. Beautifying adds
newlines and indentation around text nodes, so an element marked
xml:space="preserve"is no longer byte-identical. - Comments and the declaration are kept in both modes; nothing is stripped for size beyond the gaps between tags.
- CDATA containing an angle bracket confuses the splitter.
<![CDATA[a > b]]>is cut at the first>and reindented in two pieces.
Frequently asked questions
Does minifying XML change what it means?
Only if whitespace between elements mattered, which in mixed content it can. For record-style XML - configuration, feeds, SOAP payloads - collapsing the gaps between tags is safe and typically cuts 20 to 30 percent of the bytes.
Why does my XML fail to parse when the same text works as HTML?
XML has no forgiving mode. Every tag must be closed or self-closed, attribute values must be quoted, tag names are case-sensitive, and a bare ampersand must be written as &. HTML parsers repair all four silently.
Can I use this on an SVG or a POM file?
Yes. Both are ordinary XML, so they are checked and indented like any other document. Nothing is uploaded - the parsing and formatting run in the page.