XML

XML Minifier

Removes comments and the whitespace between elements, and reports how many bytes that saved.

Loading the tool…

Processing happens locally in your browser. What you paste or load is processed by this page and is not uploaded to a server. Nothing is stored unless you use a control that says it stores something, and you can clear anything this site has kept from the privacy page.

How to use this tool

  1. Paste the formatted XML you want compressed.
  2. Select Minify and read the byte saving in the summary.
  3. If the consumer is strict about whitespace, parse one value from both versions and compare before shipping the smaller file.

What xml minifier does

Minifying XML removes the indentation and line breaks between elements, and removes comments. What it cannot safely do is decide that whitespace is meaningless, because in XML that is a decision only the schema can make. This tool takes the common case: whitespace between two elements is layout, whitespace inside a text-only element is trimmed at each end, and everything else is left alone.

That is right for the great majority of documents — configuration, feeds, exports, SOAP payloads — and wrong for a document that uses xml:space="preserve" or a schema whose type is defined to keep leading spaces. If you are minifying something whose whitespace rules you do not control, compare a parsed value before and after rather than trusting the byte count.

Frequently asked questions

Usually, but not always. Whitespace between elements is layout in almost every document, and this tool removes it. Whitespace inside a text element is trimmed at each end. If your schema uses xml:space="preserve", or a type whose leading spaces matter, compare a parsed value before and after rather than trusting the byte count.

For an indented document, typically twenty to forty per cent, and more if it carries many comments. Over the wire most of that gap closes once gzip or Brotli is applied, so minify for storage and for smaller diffs rather than expecting a large transfer win.

Yes. Comments are for people reading the source and add nothing for a parser, so minifying drops them. If a comment in your file carries a licence header or a generated-by marker somebody downstream relies on, put it back by hand after minifying.