Skip to content
Devtoolry

XML Minifier

Minify XML online by removing whitespace between tags, with an option to keep comments. Malformed XML is reported with its location.

Runs in your browser · Nothing uploadedFree · No sign-up

Something not working, or missing a feature? Send feedback

About the XML Minifier

The XML Minifier removes comments and whitespace between tags so XML payloads and feeds are as small as possible, while keeping text content intact.

Everything runs in your browser, so your input is never uploaded to a server.

How to use the XML Minifier

  1. Paste XML or open a file.
  2. Optionally keep comments.
  3. Copy or download the minified XML.

Example

Compact an RSS item

Input

<?xml version="1.0"?>
<rss version="2.0">
  <!-- generated nightly -->
  <channel>
    <item>
      <title>Release 1.4</title>
      <link>https://example.com/releases/1.4</link>
    </item>
  </channel>
</rss>

Result

<?xml version="1.0"?><rss version="2.0"><channel><item><title>Release 1.4</title><link>https://example.com/releases/1.4</link></item></channel></rss>

The comment and the whitespace between tags are removed. Text such as "Release 1.4" is kept exactly.

Common mistakes

  • Whitespace that matters. Some formats treat whitespace between elements as content, for example xml:space="preserve" sections. Check that such documents still read correctly after minifying.
  • Removing needed comments. Comments are removed by default. Switch on "Keep comments" if a consumer reads them, such as licence headers.
  • Invalid input. The minifier parses the XML first. Fix any reported error, often an unescaped & or a mismatched closing tag, before minifying.

Works well with the XML Minifier

Frequently asked questions

Is whitespace inside text removed?

No. Only whitespace between elements is removed; text content and mixed content are preserved.

Is the XML validated first?

Yes. Malformed XML is reported with its location instead of being minified.

Are attributes changed?

No. Attribute values and their quotes are kept; only whitespace between tags and, optionally, comments are removed.

Does it work for SVG?

Yes. SVG is XML, so icons and illustrations can be minified, although an SVG optimiser can also simplify paths.