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 — 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 prolog stays 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 left editor, click Open file, or hit Sample to try it.
  2. Check the badge. "Well-formed XML" means the structure parses; a red badge quotes the parser's exact complaint.
  3. Watch the size drop. The chips show before and after byte counts and the percentage saved.
  4. Take the result. Copy it or download data.min.xml. Switch to Beautify anytime to expand it again.

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. The live badge confirms well-formedness before and after.

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 design — they're the other main source of wasted bytes. If you need comments kept, beautify instead.

Does it touch text content inside elements?

Runs of whitespace inside text content are collapsed to single spaces, which is how validating parsers treat them in data documents. If your document relies on exact text whitespace (like xml:space="preserve" regions), wrap that content in CDATA.

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.