← All tools/Minifiers/Code/XML Minifier
XML Minifier
Shrink XML to its smallest safe size — whitespace, comments and the declaration go, your data stays.
Runs in your browser — nothing is uploaded. Whitespace-only text between tags is stripped; your elements, attributes and text stay the same.
Minified XML
How it works
Remove <!-- --> comments (when ticked) and the <?xml ...?> declaration (when ticked). Strip whitespace-only text between tags: > whitespace < becomes ><. Trim the space left at the edges of text nodes. Elements, attributes and text are never changed, so the XML stays valid.
Worked example: the sample catalog above is 123 bytes when pretty-printed. Minified with comments removed and the declaration kept, it becomes 105 bytes — about 14.6% smaller — with the same elements, attributes and text: <?xml version="1.0"?><catalog><book id="1"><title>Clean Code</title><price>29.99</price></book></catalog> with the tags joined together. Nothing is dropped except whitespace between tags.
Frequently asked questions
Does minifying change my XML data?
No. Only whitespace between tags is removed, plus comments and the declaration when you tick those boxes. Every element, attribute and piece of text stays exactly the same.
Should I remove the XML declaration?
Usually not. Keep <?xml version="1.0"?> unless the system receiving the file tells you to drop it — some parsers use it to work out the encoding.
What happens to spaces inside my text?
Spaces that are part of your text stay. Only whitespace that sits between two tags, or at the very edge of a text node, is stripped — so “Clean Code” stays “Clean Code”.
Can I minify XML with comments I want to keep?
Yes — untick “Remove comments” and they are left in place. The whitespace is still stripped around them.
Is my XML uploaded anywhere?
No. Everything runs in your browser on this page. Your XML never leaves your device.
Tell us what you think
Loving this tool, or stuck on something? Tell us — it takes a minute.
We’ll only use your name and email to reply if needed. The tool and page are filled in for you.