XML Minifier
Minify XML by removing comments and inter-element whitespace.
- Runs locally in your browser
- No upload required
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Reduced 30 to 23 characters of XML.
How it works
- Removed XML comments.
- Collapsed whitespace between element tags.
- Preserved element names, attributes, CDATA and text content.
- Rejected malformed markup before transforming it.
- Whitespace between two elements is treated as formatting and removed; whitespace inside text content is collapsed to one space.
- When remove-comments is off, comments are preserved verbatim.
- Output is 23 character(s); minifying it again changes nothing.
Methodology
- Tokenise the markup with the shared quote-aware scanner so `>` inside an attribute cannot end a tag.
- Check well-formedness with an element stack and fail closed on a mismatch.
- Emit tags with normalised whitespace, drop inter-element text nodes and optionally remove comments.
Usage
- Paste or type an XML document.
- Choose whether to remove comments.
- Run the minifier and copy the compact result.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Elements collapsed
{
"text": "<a>\n <b>1</b>\n <b>2</b>\n</a>",
"removeComments": true
}Comment removed
{
"text": "<!-- note --><a>x</a>",
"removeComments": true
}CDATA preserved
{
"text": "<a><![CDATA[ raw ]]></a>",
"removeComments": true
}Limitations
Why minify XML
Whitespace between elements and comments are often the largest avoidable part of a generated XML document. Removing them shrinks the payload without changing the data.
Because the tool verifies well-formedness first, a malformed document is reported rather than silently narrowed.
Frequently asked questions
- Does minifying change my XML data?
- No. Element names, attributes, CDATA and text are preserved; only comments (when selected) and inter-element whitespace are removed.
- What happens to malformed XML?
- A mismatched or unclosed tag is rejected with a line and column instead of being silently transformed.
- Is my XML uploaded?
- No. All processing happens in your browser and nothing is sent anywhere.
Sources
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.