XML Minifier
Minify XML instantly — strip whitespace between tags, collapse extra spaces inside text content, and optionally remove comments, while leaving attribute values and CDATA sections untouched. Runs entirely in your browser.
Input
Settings
Output
Guides
Paste XML, get it back with every byte of incidental whitespace stripped — no indentation, no line breaks between tags, comments removed by default. This free online XML minifier shrinks config files, API payloads, SOAP envelopes and RSS/Atom feeds before you ship or store them, without touching the data that actually matters: attribute values and CDATA content are copied through byte-for-byte. Minification happens as you type, with no upload and no sign-up.
How to use it
- Paste your XML into the input box, or drop an
.xmlfile onto the uploader. - Toggle Remove comments off if you need to keep
<!-- ... -->blocks in the minified output (on by default). - Copy or download the result as
minified.xml.
The output updates automatically as you type.
What exactly gets removed?
Whitespace that exists purely for layout — the indentation and line breaks between <tag> and <tag> — is dropped entirely. Whitespace inside real text content is collapsed: a run of spaces, tabs or newlines becomes a single space, but a lone space that separates two words (or sits between an inline element and the word next to it, like Hello <b>world</b>) is preserved so mixed content doesn't get mashed together. Comments are stripped by default; uncheck the option to keep them.
What's left untouched?
Attribute values and CDATA sections are copied through exactly as written, including any internal whitespace — title="two spaces" keeps both spaces. An element's original self-closing form is preserved too: a tag that was already self-closed (<empty/>) stays that way, and an explicitly empty non-self-closing tag (<notes></notes>) stays as two tags rather than being rewritten. Minifying strips layout, not markup shape.
Why not just use a regex like .replace(/\s+/g, ' ') on the whole file?
That's what naive minifiers (including this tool's own legacy predecessor) do, and it's unsafe: a single global whitespace-collapsing regex doesn't know the difference between layout whitespace between tags and meaningful whitespace sitting inside a quoted attribute value or a CDATA block — it collapses both, silently corrupting data it has no business touching. This tool parses the document into a small tree first, so it can make that distinction correctly.
What if my XML is malformed?
The minifier parses XML well-formedness — matching tags, a single root element, properly quoted attributes — and reports a clear error naming the specific problem instead of guessing at broken markup.
Is my data private?
Completely. Parsing and minifying run entirely in your browser using a self-contained XML parser — your data is never sent to a server, logged, or stored.
What if I want the opposite — readable, indented XML?
Use the XML Formatter to pretty-print minified or single-line XML back into an indented, readable document.