XML Minifier
Compress XML by removing comments and the whitespace between tags — text and CDATA pass through untouched.
For XML, minifying has to be a smaller promise than it is for HTML or CSS, because XML parsers are allowed to treat whitespace inside content as data. So this tool removes exactly two things: XML comments, and the whitespace that sits strictly between two tags — the indentation a formatter or a human added. Nothing inside a text node is collapsed, trimmed or reflowed. <a><b>1</b></a> written across three indented lines minifies back to exactly <a><b>1</b></a>, and a value written as <name> Emma Jane </name> keeps every one of its spaces, because a downstream parser may mean them. The saving is therefore modest and honest: heavily indented documents typically give up 10–25%, all of it layout.
Minifying runs in this browser only — your XML is never uploaded, stored or put into a link. Only the whitespace between tags and XML comments are removed; text content and CDATA sections are passed through character for character, because in XML whitespace inside content can be meaningful.
Quick answers
How do I minify XML safely?
Remove comments and only the whitespace that sits strictly between tags — never whitespace inside text nodes. Three indented lines of <a><b>1</b></a> minify to the single line <a><b>1</b></a> with the value untouched.
CDATA sections must be preserved verbatim as well; this tool lifts them out before minifying and restores them character for character.
Is whitespace significant in XML?
Between tags, almost never — that is indentation. Inside text content, it can be: parsers may pass it through as data, and applications decide what it means. Safe minifying touches only the first kind.
That is why XML minifiers promise smaller savings than HTML ones, and why mixed-content documents should not be minified at all.
How to use
- Paste your XML into the top box.
- Read the minified result and the size line — characters before and after, and the percentage saved.
- Spot-check a text node and any CDATA section in the result: both are preserved exactly, by design.
- Copy the minified XML out, and keep the indented original as the version you edit.
About this tool
CDATA sections get the same protection, for the same reason: their contents are literal text by definition, so the minifier lifts each <![CDATA[…]]> block out before removing anything and restores it character for character — a CDATA block containing the characters > < survives intact, where a naive “remove all space between > and <” pass would corrupt it. One consequence to know: if your XML relies on mixed content with meaningful whitespace between text and child elements, no inter-tag whitespace remover can tell your meaningful gaps from indentation — documents like that should not be minified at all, and this page would rather be the tool that says so.
Frequently asked questions
Why is the saving smaller than an HTML minifier’s?
Because XML whitespace can be data. This tool removes only comments and the gaps strictly between tags; an HTML minifier can also collapse spaces inside text, which XML forbids a careful tool from doing. Expect roughly 10–25% on indented documents — all layout, no content risk.
Are CDATA sections safe?
Yes — they are the explicit test case. Each CDATA block is lifted out before anything is removed and restored verbatim, so contents like “x > < y” or embedded markup samples pass through unchanged. A minifier that treats the whole file as plain text cannot promise that; this one is built around it.
What happens to whitespace inside a text value?
Nothing. <name> Emma Jane </name> keeps its leading, trailing and double spaces exactly. Only whitespace that is entirely between two tags (> … <) is removed, which is the whitespace that exists purely because someone indented the file.
Should I minify XML that contains mixed content?
No — and that is a property of XML, not of this tool. In mixed content (text interleaved with elements, like marked-up prose), the spaces between text and tags may be meaningful, and no automated pass can tell them from indentation. Keep such documents formatted instead.
First time embedding? Read the step-by-step guide →
More free tools
UUID Generator
Generate random v4 UUIDs in bulk.
JSON Formatter & Validator
Format, minify and validate JSON in one click.
What Is My IP
See your public IP address instantly. No sign-up, nothing stored.
Regex Tester
Test, check and validate regular expressions with live highlighting.
JWT Decoder
Decode a JWT token without the secret — see its header and payload.
SHA-256 Hash Generator
Generate SHA-256 / SHA-512 hashes instantly.