
Minify and format XML safely
This XML compressor removes indentation, line breaks between tags, and comments, the formatting that makes XML readable but bigger. It can also go the other way and indent compressed XML so you can read it. What it won't do is remove whitespace that's part of your content. Then it can pack the result as .gz or .zip.
Everything runs in your browser. Feeds, configs, and data exports never leave your computer.
How to use it
- Paste XML, open an
.xml,.svg,.rss,.xsl, or similar file, or drag it onto the tool. - Choose Minify, or a Pretty option to indent it.
- Copy the result or download it as XML,
.gz, or.zip.
Which whitespace is safe to remove?
XML has no single rule for this, which is why careless minifiers break documents. Spaces between tags are usually just indentation, but in mixed content, where text and tags sit side by side, they're part of the text:
<p>Hello <b>big</b> <i>world</i></p> ← the space between </b> and <i> is real textRemove it and "big world" becomes "bigworld." This tool follows conservative rules:
| Situation | Handled as |
|---|---|
| Indentation between child elements of an element with no text of its own | Removed |
| Mixed content (text and tags together) | Kept exactly |
An element whose only content is spaces, like <name> </name> | Kept. The spaces are its value. |
xml:space="preserve" and elements like pre, script, style, SVG text, and xsl:text | Kept exactly |
| CDATA sections, the DOCTYPE, processing instructions, entities, and attribute values | Kept exactly |
| Extra spaces between attributes inside a tag | Reduced to one space |
| Comments | Removed, unless you choose to keep them |
Checked twice
Every result is checked automatically. The minifier itself validates that the XML is well-formed, so tags must match, & must be escaped, and so on. Then your browser's own XML parser reads both the original and the result, and the tool compares the two document trees. The green Verified badge means they hold the same elements, attributes, and text. During development, results were also checked against lxml and xmllint on real-world files, including SVG icons, ISO standard data, LibreOffice and Excel document XML, and a deliberately tricky test file.
Frequently asked questions
Is my XML uploaded?
No. Everything happens in your browser.
Can I use it for SVG files?
Yes. Indentation is removed and text inside SVG <text> elements is protected. For deeper SVG optimization, like simplifying paths or removing editor metadata, use a dedicated SVG optimizer.
Why is my file "not valid XML"?
The tool reports the exact line and column. Common causes are an unescaped & (write &), a tag that isn't closed, or tags closed in the wrong order. Browsers and other software reject these files too.
What about files that aren't UTF-8?
The tool reads the encoding from the XML declaration or byte order mark, so ISO-8859-1, Windows-1252, and UTF-16 files are decoded correctly. The result is saved as UTF-8, and the declaration is updated to match.
Should I collapse empty elements?
Turning <a></a> into <a/> is equivalent in XML, but it can break XHTML pages served as HTML, where <script/> doesn't work. That's why it's off by default.
