Input

Minified Output

Minified XML appears here

Paste or type XML in the panel on the left and the space between tags comes out as you go.

The XML Minifier

A pretty-printed subscriber.xml — one element per line, two-space indentation, easy to review in a diff — is 209 bytes for a single record with six fields. Strip the indentation and it drops to 190, a number that only gets more worth having as the document grows: a thousand of those records ship roughly 19 KB lighter with nothing about the parsed tree changing at all. XML Minifier parses your document with the browser's own DOMParser, re-serializes it with XMLSerializer, and collapses the whitespace that exists only for a human reader's benefit.

The part worth understanding is what counts as "only for a human reader": whitespace sitting between two tags with nothing else between them is formatting and gets dropped, but a <![CDATA[...]]> section is left completely untouched — which matters more than it sounds, because RSS and Atom feeds routinely wrap an HTML fragment in one, and a naive whitespace collapse that reaches inside the CDATA payload changes what that fragment renders as. Same for text sitting next to other text: <pre>-style content with its own internal line breaks comes back exactly as written. For background on the format itself, see the W3C XML page.

How to Use XML Minifier

  1. Paste Your XML – Copy your formatted XML and paste it into the input panel, or load an XML file using the "Upload" button.
  2. Auto-Minify – The tool minifies as you type. Whitespace and line breaks between tags are stripped instantly, while the text inside your elements is preserved untouched.
  3. Review the Output – Your compressed XML appears in the output panel as a single line, semantically identical to what you started with.
  4. Copy or Download – Click "Copy" to put the minified XML on your clipboard, or "Download" to save it as a .xml file.

Pro Tip: Minification only touches whitespace between tags. If an element holds significant whitespace (for example inside a <pre>-style block or a CDATA section), that content is left exactly as it was.

Example

A single telecom subscriber record — indented and easy to scan on the left, collapsed to one line on the right. Same elements, fewer bytes.

Formatted → Minified Compress
subscriber.xmlXML · 8 lines · 209 B
<subscriber id="1">
  <subscriberId>SUB-1001</subscriberId>
  <msisdn>447700900142</msisdn>
  <imsi>234150999912345</imsi>
  <plan>Unlimited 5G</plan>
  <roaming>true</roaming>
  <rsrp>-92</rsrp>
</subscriber>
subscriber.min.xmlXML · 1 line · 190 B
<subscriber id="1"><subscriberId>SUB-1001</subscriberId><msisdn>447700900142</msisdn><imsi>234150999912345</imsi><plan>Unlimited 5G</plan><roaming>true</roaming><rsrp>-92</rsrp></subscriber>

Common Use Cases

SOAP and Web Service Payloads

SOAP envelopes are famously verbose. Stripping the whitespace between elements before sending shrinks every request and response on the wire without changing a thing the server reads. On a busy integration that fires thousands of calls an hour, the saved bandwidth is real. The XML 1.0 specification spells out exactly which whitespace is insignificant and safe to drop.

RSS Feeds and Sitemaps

XML sitemaps and RSS/Atom feeds are fetched constantly by crawlers and readers. Serving them minified cuts the transfer size on every hit. Because the structure is unchanged, parsers handle the compact form identically — see the MDN XML introduction for how documents are parsed.

Embedded Configuration

Bundling XML config inside an app or build artifact? Minifying first keeps the footprint small. For more on the format and common patterns, MDN's XML documentation is a solid reference.

Key Features

  • Instant Minification – Compresses XML as you type
  • Whitespace Stripping – Removes line breaks and indentation between tags
  • Content Preserved – Text inside elements is never altered
  • File Upload – Load XML files directly for minification
  • Validation – Catches malformed XML before minifying
  • Privacy First – All processing happens in your browser

Frequently Asked Questions

Does minifying change my XML data?

No. It only removes whitespace and line breaks between tags. Element names, attributes, and the text inside elements are untouched, so the minified document parses to the same tree as the original.

Will it strip whitespace inside my element text?

No, as long as there is other content alongside it — text next to real words, or inside a <![CDATA[...]]> section, survives byte for byte, which matters for an RSS <description> that embeds a chunk of HTML. Only the formatting whitespace sitting between two tags with nothing else between them is collapsed. The one edge case worth knowing: an element whose entire content is nothing but whitespace (rare, but it happens) collapses the same way indentation does, because there is no way to tell "meaningful blank" apart from "layout blank" once it is just spaces.

Can I minify invalid XML?

No. The tool parses your input first with DOMParser. If a tag is unclosed or mismatched, you'll get an error instead of broken output. For help debugging XML errors, the XML tag on Stack Overflow is a good place to look.

Is my data safe?

Yes. Everything runs locally in your browser. Your XML is never uploaded to a server, so even sensitive payloads stay on your device.

Related Tools