How to use the XML Minifier
- Paste XML or open an
.xml,.rssor.svgfile. - The document is checked for well-formedness; errors show the line.
- Choose whether to remove comments and trim whitespace around text values.
- Copy or download the minified XML.
What does XML minification do?
XML is often pretty-printed with indentation and line breaks to make it readable. For machines those characters are just extra bytes. An XML minifier removes whitespace between tags, normalises spacing inside tags and optionally strips comments, while leaving element text, attribute values, CDATA sections and processing instructions exactly as they were.
What is preserved
| Part | Handling |
|---|---|
<?xml … ?> declaration | Kept |
<!DOCTYPE> and internal subsets | Kept |
<![CDATA[ … ]]> | Kept byte for byte |
| Text inside elements | Kept (optionally trimmed) |
| Whitespace-only text between tags | Removed |
| Comments | Removed (optional) |
A note on mixed content
In document-style XML such as XHTML or DocBook, whitespace between inline elements can be meaningful (<b>bold</b> <i>text</i>). Whitespace-only nodes are removed by design, so check such documents before using the result, or keep them formatted. Data-oriented XML — feeds, configs, API payloads, sitemaps — is always safe.
Typical uses
- Shrinking SOAP and XML API requests and responses.
- Compacting RSS/Atom feeds and product feeds for merchant platforms.
- Reducing the size of XML sitemaps and configuration files stored in databases.
To go the other way, use the XML formatter. SVG files are XML too, but the SVG optimizer saves much more by also simplifying paths and removing editor metadata.
Tools that pair well with the XML Minifier
- JSON Minifier — Remove all unnecessary whitespace from JSON, validate it at the same time and see exactly how many bytes you save — before and after gzip.
- HTML Minifier — Shrink HTML pages and templates by removing comments and redundant whitespace, minifying inline <style> and <script>, and cleaning up attributes — while keeping the layout identical.
- Gzip Compress & Decompress — Compress text or any file with gzip, zlib or raw deflate — or paste Base64 / open a .gz file to decompress it.
- Brotli Compress & Decompress — Compress text or files with Brotli at any quality from 0 to 11, decompress .br data, and compare the result against gzip — all locally in your browser.
Frequently asked questions
Does minified XML still validate?
Are CDATA sections changed?
Why do I get a “not well-formed” error?
& or two root elements. The line number points to where the parser stopped.