Mode
Paste XML, open a file or press Sample. The check runs as you type and names the line and column of any error.
Send the result to: XML Formatter

About the XML Minifier

What is an XML minifier?

An XML minifier collapses a formatted document onto a single compact line by removing the indentation and line breaks between elements, and stripping comments. For data-centric XML such as RSS and Atom feeds, sitemaps, SOAP payloads, configuration files, API responses, that whitespace is purely cosmetic, and removing it can cut file size by a third or more before gzip.

What must survive untouched are the parts where bytes carry meaning: <![CDATA[...]]> sections come through byte-for-byte, attribute values keep their exact spacing (even a literal > inside a quoted value is handled correctly), entities like &amp; are never re-encoded, and the XML declaration, DOCTYPE and processing instructions stay in place. A live well-formedness check flags structural errors as you type, so you can't compress a broken document without noticing. Everything runs in your browser; nothing is uploaded.

How to Use This Tool

  1. Add your XML. Paste it into the input editor, drop a file on it, click Open file, or hit Sample to try it.
  2. Read the status line. "Well-formed XML" means the structure parses. Otherwise it names the first problem with its line and column, and Go to line jumps to it.
  3. Watch the size drop. The size next to each editor shows the bytes before and after, and the output adds the percentage saved.
  4. Take the result. Copy it or download minified.xml. Switch on Keep comments to leave comments in, or switch to Beautify anytime to expand the XML again.

Example

Comments and the whitespace between tags go, and this will be converted to 65 bytes:

Input: 106 bytes
<library>
    <!-- catalog -->
    <book id="b1">
        <title>Clean Code</title>
    </book>
</library>
Output: 65 bytes
<library><book id="b1"><title>Clean Code</title></book></library>

Whitespace between elements is removed, but text inside an element is left alone, because in XML that content can be significant and the parser has no way to know it is not.

Common Use Cases

  • Compressing feeds and sitemaps: Shrink RSS files and XML sitemaps that are served on every crawl.
  • SOAP and API payloads: Compact request and response bodies before embedding them in tests or logs.
  • Config distribution: Minify build and deployment descriptors that ship inside packages.
  • Storage and caching: Reduce the footprint of XML documents stored in databases or caches.

Need it readable instead? The XML Formatter beautifies with the same engine, and the XML to JSON Converter restructures your data entirely. Or browse all our free developer tools.

Frequently Asked Questions

Is minified XML still valid?

Yes. Whitespace between elements is insignificant in data-centric XML, so removing it produces a document that parses into the same structure, and the status line confirms the input is well-formed as you type.

What happens to CDATA sections and comments?

CDATA sections are preserved byte-for-byte, including all internal whitespace and special characters. Comments are removed by default, since they're the other main source of wasted bytes, and the Keep comments switch leaves them in.

Does it touch text content inside elements?

No, text inside elements is kept exactly as written, spaces and line breaks included. Only the whitespace between tags is removed, and elements that mix text with tags or use xml:space to preserve whitespace keep their spacing too.

Are attribute values safe?

Yes, completely. Values keep their exact contents (internal double spaces, greater-than signs, entities) because the tokenizer understands quoting rather than splitting on characters.

Can it minify SVG files?

Yes. SVG is XML, and the file picker accepts .svg directly. For an SVG-focused workflow with a matching sample and download name, use our dedicated SVG Formatter's minify mode.

Is my XML uploaded anywhere?

No. Minification runs entirely in your browser with self-contained JavaScript, no CDN, no server round trips, no logging. It even works offline once the page has loaded.