← All tools
// CODE

XML Minifier online

Strip whitespace and comments from XML — reduce payload size for production.

XML Minifier logo
by
CHUNKY
MUNSTER
XML INPUT0 CHARS
MINIFIED OUTPUT0 CHARS

About XML Minifier

This tool removes XML comments, strips leading/trailing whitespace from text nodes, and collapses whitespace between elements. The result is a compact, single-line XML document that is functionally identical but smaller in byte size — useful for APIs, sitemaps, and configuration files. All processing happens in your browser.

How to Use the XML Minifier

  1. Paste or enter your input into the text field.
  2. Configure any options (format, delimiter, encoding, or mode) using the controls above the output.
  3. The result updates instantly — no submit button required for most operations.
  4. Click Copy or Download to take the output to your next step.

Compress an XML document by stripping the parts that parsers ignore: comments (<!-- … -->), whitespace between elements (>\s+<), and runs of more than one consecutive space inside text. The result is functionally identical XML — it parses to the same DOM — just smaller and faster to transmit.

How the XML Minifier Works

Useful for production sitemaps, SOAP envelopes, RSS feeds, and any XML payload that’s served over the wire repeatedly. Before/after byte counts and percent saved are shown after each run. For mixed-content XML where inter-element whitespace is meaningful (some XHTML, MathML), keep the original or use a parser-aware minifier.

Frequently Asked Questions

Is whitespace inside text nodes preserved?

Yes — only whitespace between tags and runs of more than one space inside text are touched. Single spaces, line breaks, and tabs that are part of meaningful text content are kept. For mixed-content XML where whitespace is significant (some XHTML, MathML), turn the space-collapse option off.

Will the minified XML still parse?

Yes — the tool only strips characters that XML parsers ignore. The element tree, attribute order, and CDATA sections are unchanged. Run the output through an XML validator if you want to be sure.

How much size reduction can I expect?

Hand-formatted XML typically shrinks 20–60 % depending on indentation and comment volume. Sitemaps, SOAP envelopes, and RSS feeds with deep nesting see the biggest savings.

Is the XML uploaded anywhere?

No — minification is a local JavaScript regex pass. Nothing leaves the page.

Explore the full suite of CODE tools and 290+ other free utilities at Chunky Munster.