📐 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

Well-formed is not the same as valid. This page checks nesting, quoting and a single root element - it never looks at a DTD or an XSD, so a document can pass here and still be rejected by a schema.

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 &amp;. 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.