XML Minifier
Remove all whitespace and comments from XML for compact output. Namespace prefixes are preserved.
What minification does
XML minification removes all insignificant whitespace — indentation, newlines, and spaces between elements — and strips comments. The result is semantically identical to the original but occupies the minimum possible bytes, making it ideal for wire transfer and storage.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Server config -->
<config>
<server>
<host>localhost</host>
<port>8080</port>
</server>
</config><?xml version="1.0" encoding="UTF-8"?><config><server><host>localhost</host><port>8080</port></server></config>
What is preserved vs stripped
| XML construct | After minification | Notes |
|---|---|---|
| Element content (text) | Preserved | Text nodes kept exactly as-is |
| Attributes | Preserved | Including whitespace in values |
| Namespace declarations | Preserved | Required for valid XML |
| Processing instructions | Preserved | e.g. <?xml-stylesheet?> |
| Indentation / newlines | Stripped | Between elements only |
| XML comments | Stripped | <!-- --> blocks removed |
| CDATA sections | Preserved | Content is significant |
| Whitespace in text nodes | Preserved | User content may be space-sensitive |
When to minify
Minification is most valuable when XML is transmitted over a network (REST APIs, SOAP payloads, RSS feeds) or stored in space-constrained environments. Well-formatted XML typically achieves 20–60% byte reduction through minification alone. Combine with gzip compression for maximum reduction — XML compresses very well due to tag repetition.
Frequently Asked Questions
Your files stay on your computer. Dad promised.