XML Minifier

Remove comments and the whitespace between tags from XML, keeping CDATA sections and text intact.

Processed on your device. Files are not uploaded

How to minify XML

  1. Paste your XML

    Paste or type it into the box, or press Try an example.

  2. Choose whether to remove comments

    Comments are removed by default.

  3. Copy or download

    Use the compact XML where size matters.

Worked example

This is what XML Minifier gives for its own sample values. Open the tool above and change anything to try your own.

XML

<?xml version="1.0"?>
<!-- catalog -->
<catalog>
  <book id="1">
    <title>Dune</title>
  </book>
</catalog>
Remove comments
Yes

Minified

<?xml version="1.0"?><catalog><book id="1"><title>Dune</title></book></catalog>

About XML Minifier

Remove comments and the whitespace between tags from XML. Text inside elements is kept, runs of spaces inside text become one space, and CDATA sections are left exactly as they are.

FAQs

Is the meaning preserved?

For normal data, yes. If your format treats whitespace in text as significant, check the result.

Can I check the XML is valid?

Use XML Validator.

Can I make it readable?

Use XML Formatter & Validator.

Related tools