Micru Logo

Minify XML

Compress XML by stripping whitespace and comments, reducing file size for transmission and storage.

All processing is done locally in your browser. No data is sent to our servers.

What is XML Minification?

XML minification removes all non-essential whitespace - indentation, line breaks, and the spaces between element tags - to produce the smallest possible valid XML document. The resulting file carries identical data to the original but in a compact, single-line (or near-single-line) form that is faster to transmit and cheaper to parse.

Comments are also stripped during minification: they contribute bytes to the wire but carry no machine-readable data. Processing instructions (<?xml ... ?>) are retained because parsers and processors depend on them for encoding and version declarations.

What Gets Removed

Inter-element Whitespace

Newlines, tabs, and spaces that appear between closing and opening tags - purely for human readability - are eliminated. Text node content inside elements is kept intact.

Comments

All <!-- ... --> comment nodes are dropped. They are never parsed by XML processors in data pipelines, so their removal has no semantic effect.

Empty Text Nodes

Whitespace-only text nodes between sibling elements (e.g. a newline + spaces between </a> and <b>) are discarded. Mixed-content text is preserved.

What is NOT removed

Attribute values, text node content, CDATA sections, and processing instructions are left completely unchanged. Significant whitespace inside elements is preserved.

How Much Does Minification Save?

The savings depend entirely on how heavily indented the source document is. A deeply nested XML file with 4-space indentation can see a 30-60% reduction in raw byte count. A flat document with only one or two nesting levels might shrink by just 10-15%.

For network delivery, pair minification with gzip or Brotli compression. Minified XML still compresses well because the repeated element names are highly redundant. In practice, gzip-compressed minified XML is often only marginally smaller than gzip-compressed pretty-printed XML - but minification reduces the work done by the decompressor and parser on the receiving end.

Common Use Cases

SOAP Payloads

SOAP messages can grow very large. Minifying the XML envelope before sending reduces bandwidth usage and speeds up serialisation/deserialisation in high-throughput service integrations.

Embedded & IoT Devices

Devices with limited RAM benefit from receiving compact XML that fits in smaller buffers. Configuration files deployed to edge devices are often minified before packaging into firmware images.

Stripping Developer Comments

Internal XML configs often contain developer notes that should not ship to production. Minification removes all comments in one pass, eliminating the risk of accidentally leaking internal documentation.

Database Storage

XML stored in database columns (e.g. SQL Server's xml type or PostgreSQL's text) takes less space when minified, reducing storage costs and improving query performance on large datasets.