XML Minifier Online — Compress XML & Remove Whitespace

Strip whitespace between tags, remove comments, and compact attributes to shrink XML payloads by 20–40% for bandwidth and storage savings — 100% in your browser.

What is XML Minification?

XML minification rewrites a document to occupy the fewest possible bytes while remaining functionally identical: whitespace between tags is stripped, comments are removed, and the result is a single line of dense, parser-ready markup. It is the inverse of pretty-printing.

Minification matters wherever XML touches the wire or the disk. SOAP middleware billed by message size, RSS feeds served by a CDN, configuration files baked into a Docker image, or message-bus payloads pushed through Kafka all benefit from the 20–40% size reduction that whitespace removal alone provides. The OpenFormatter minifier runs entirely in JavaScript — your payload never leaves the browser.

How to minify XML online — 4 steps

  1. Paste your XML. Drop a SOAP envelope, RSS feed, config file, or any indented XML into the Input panel. Click Load Sample to try a demo book catalogue.
  2. Click Minify. The tool parses the document with the browser's DOMParser, then re-serializes without inter-element whitespace.
  3. Verify the size delta. Compare character counts in the Input vs Output panes — most documents shrink by 20–40%.
  4. Copy the result. Use the Copy button to send the compact XML to your storage layer, network call, or build artifact.

Sample input vs minified output

Before — 187 chars

<?xml version="1.0"?>
<!-- Catalogue -->
<catalog>
  <book id="bk101">
    <author>Gambardella</author>
    <title>XML Guide</title>
    <price>44.95</price>
  </book>
</catalog>

After — 124 chars (-34%)

<?xml version="1.0"?><catalog><book id="bk101"><author>Gambardella</author><title>XML Guide</title><price>44.95</price></book></catalog>

Whitespace Stripping

Removes every space, tab, and newline between elements while preserving whitespace inside text nodes and CDATA — only the layout is lost.

Comment Removal

XML comments add bytes without semantic value at runtime. Stripping them shaves additional weight off configuration and feed documents.

CDATA Preserved

Anything inside <![CDATA[ ... ]]> is opaque to the minifier — useful for embedded HTML, JSON, code, or text where whitespace matters.

Common use cases

  • check_circleCompressing SOAP API payloads to cut bandwidth on per-byte API gateways
  • check_circleShrinking RSS, Atom, and podcast feeds before serving from a CDN
  • check_circleReducing XML log files for archival and long-term storage cost savings
  • check_circlePreparing XML message-bus payloads for Kafka, RabbitMQ, or AWS SQS limits
  • check_circleCompacting Spring, log4j, or .NET config files baked into Docker images
  • check_circleEmbedding XML literals in source code without indent bloat
  • check_circleMinimising XML attachments in SAML assertions and WS-Security envelopes
  • check_circlePreparing XML for embedded device protocols where bytes are expensive

Minify vs gzip — why both?

Minification and gzip stack: minifying first, then gzipping, gives a smaller wire size than gzipping the indented source directly. Beyond bytes, minification also speeds up parsing — the DOM tree built from a minified document has fewer empty text nodes, which matters in hot SAX/StAX paths. And not every transport gzips: legacy SOAP middleware, AS2 EDI exchanges, and many embedded protocols still ship raw bytes, so minification is the only lever you have.

Need to do the opposite — or something else?

Re-format minified XML for review, validate it before shipping, or convert it to JSON — all browser-side.

Frequently Asked Questions

What exactly does the minifier strip out of my XML?

Three things. First, whitespace between elements (the indentation and blank lines you added for readability). Second, XML comments (<!-- ... -->) — they carry no semantic value at runtime. Third, redundant whitespace inside tags themselves. The minifier never alters element names, attribute values, or text content.

Are CDATA sections preserved?

Yes. Anything inside <![CDATA[ ... ]]> is treated as opaque content — the parser hands it through to the serializer untouched. CDATA is the standard XML escape hatch for embedding HTML, JSON, code, or significant whitespace, so the minifier deliberately leaves it alone.

How much size reduction should I expect?

Typical reductions are 20–40%. Heavily-indented configuration files (Spring, log4j) tend toward the high end because every nested element carries 4–8 spaces of indent. Data-dense XML (RSS feeds, SOAP responses) sits at the lower end because most of the bytes are actual content. Add gzip on top and you reach 70–85% over the original.

Will minification ever break my XML?

No. The minifier parses your input through DOMParser before serializing — if the round-trip succeeds, the output is well-formed XML by construction. Whitespace inside attribute values and text nodes is preserved exactly, so anything semantically significant survives.

Why minify XML when gzip already compresses it?

Three reasons. First, not every transport gzips: some legacy SOAP middleware, message buses, and embedded device protocols send raw bytes. Second, smaller raw XML parses faster — the DOM tree built from minified input has fewer text nodes. Third, billing on per-byte API gateways (AWS API Gateway, Azure API Management) charges for the wire size after gzip but before transport, so minification still saves money.

Does removing comments matter for production?

In a production payload, almost never — XML parsers ignore comments by default. Strip them to save bytes. Keep them only if your tooling specifically reads comments (some XSLT pipelines and signed-XML workflows do).

Can I un-minify the output later?

Yes. Run the minified XML through the XML Formatter tool on this site to restore indentation. The semantic content is identical to the original — only the layout was lost — so the round-trip is lossless for everything except the comments you stripped.

Is my XML uploaded anywhere?

No. The minifier runs in JavaScript on your machine using the browser's built-in DOMParser and XMLSerializer. Open DevTools → Network and confirm: clicking Minify produces zero network requests. Safe for SOAP envelopes that contain credentials, signed payloads, or PII.

XML Minifier Online — Compress XML & Strip Whitespace