Skip to content

XML Minifier

Shrink XML by removing indentation and comments while keeping every value intact.

Original
316 B
Minified
206 B
Saved
110 B (34.8%)

XML input

Tab inserts indentation. Press Escape, then Tab, to move focus out of the editor.

Minified XML

How to minify XML

  1. Paste XML on the left, or open or drop an .xml file.
  2. The minified XML appears on the right, with the size before and after.
  3. Choose whether comments are removed, then copy or download the result.

Remove whitespace, keep the data

The XML minifier parses your document and rebuilds it without the indentation and line breaks between elements. Whitespace that belongs to your data — text inside elements, CDATA sections, mixed content and xml:space="preserve" — is kept, so the result means exactly the same to any XML parser.

Before
<sizes>
    <size>S</size>
    <size>M</size>
</sizes>
After
<sizes><size>S</size><size>M</size></sizes>

Use cases

  • Reduce the size of SOAP messages, XML API payloads and product feeds.
  • Shrink SVG icons before inlining them in HTML or CSS.
  • Store large XML exports more compactly.

Related tools

To make XML readable again, use the XML formatter. If minifying reports an error, the XML validator explains it. For other formats there's the JSON minifier and the HTML minifier.

Frequently asked questions

What does the XML minifier remove?
Indentation and line breaks between elements, and optionally comments. Text inside elements, CDATA sections and attribute values are not changed.
Is whitespace in text preserved?
Yes. Whitespace is only removed where it separates elements. In elements that mix text with child elements, or that use xml:space="preserve", all whitespace is kept.
When is minifying XML useful?
For XML sent over a network or stored in bulk — SOAP messages, API payloads, sitemaps, SVG icons embedded in pages — where every byte counts. Keep a formatted copy for editing.