XML Minifier
Strip the comments and inter-tag whitespace out of XML to get compact markup that's ideal for SOAP envelopes, RSS feeds and config payloads.
How XML minification works
XML documents are often pretty-printed with one element per line and generous indentation so the tree is easy to read. That indentation is whitespace sitting between tags, and for most documents it carries no meaning — so a minifier can safely remove it to produce far more compact markup.
This tool does two things: it strips <!-- comments -->, then removes the whitespace between adjacent tags so > < collapses to ><. Crucially, it only touches the whitespace between tags — text content inside an element is left exactly as written.
Everything runs locally in your browser, so SOAP envelopes, build configs and internal API payloads are never transmitted anywhere.
Compressing XML in four steps
- 1
Paste your XML
Add the document to the input pane, or upload an .xml file.
- 2
Get compact markup
Comments and inter-tag whitespace are removed, leaving tight markup on the right.
- 3
Verify the content
Check that element text and attributes look right before you use the output.
- 4
Copy or download
Take the minified XML to your clipboard or save it as an .xml file.
Where compact XML is useful
Lighter API messages
Trimming whitespace shrinks SOAP and REST-over-XML payloads on every call.
Tighter feeds and configs
RSS, Atom and build-config files get smaller without losing any element data.
Content stays intact
Only whitespace between tags is removed; the text inside your elements is untouched.
Private and offline
Documents are processed in your browser, so internal payloads never leave your machine.
Before and after
An indented, commented document on the left; the compact markup on the right.
<catalog>
<!-- featured -->
<book id="bk101">
<title>XML Guide</title>
<price>44.95</price>
</book>
</catalog><catalog><book id="bk101"><title>XML Guide</title><price>44.95</price></book></catalog>Why only inter-tag whitespace is removed
In XML, whitespace inside an element's text content can be significant — it may be exactly what a consumer expects to read. Whitespace between tags, used purely for indentation, almost never is. This minifier deliberately targets only the latter (>\s+<), so the visible content of your document is preserved while the formatting bloat is removed. If you have elements where surrounding whitespace genuinely matters, review the output to be sure.
What gets removed and what stays
- Removed:
<!-- … -->comments anywhere in the document. - Removed: whitespace and newlines sitting between two tags.
- Kept: element names, attributes and their values, exactly as written.
- Kept: the text content inside each element, untouched.
Frequently asked questions
No. This is a text-based minifier — it removes comments and inter-tag whitespace but doesn't parse the document or check that every tag is closed. Use an XML beautifier or validator if you need a well-formedness check.
Yes. The tool only collapses whitespace between tags. The text content inside an element is left exactly as you wrote it, including any internal spacing.
Yes. SVG is XML, so you can minify SVG markup the same way. Just be mindful that whitespace inside text elements is preserved, which is usually what you want.
Attribute names and values are kept exactly as written — they aren't reordered, deduplicated or altered. Only comments and inter-tag whitespace are removed.
No. The transformation runs entirely in your browser, so SOAP envelopes, configs and other private payloads stay on your machine.
You can re-indent compact XML with an XML beautifier to make it readable again, but comments removed during minifying can't be recovered. Keep your source if you need them.
Need another tool?
Browse the full toolbox or dig into the blog for the engineering behind it.