XML Minify

Remove whitespace between XML tags to shrink the file.

Local Your input is processed locally in your browser. Found a problem? Report an issue

What XML Minify does

XML Minify removes whitespace between tags after checking that the XML is well-formed, which puts an indented document on a single line. Whitespace inside text content is kept.

XML Minify examples

The built-in sample

Input

<users>
  <user id="1">
    <name>Ada</name>
  </user>
  <user id="2">
    <name>Lin</name>
  </user>
</users>

Output

<users><user id="1"><name>Ada</name></user><user id="2"><name>Lin</name></user></users>

This is the input that the Load sample button fills in.

Which whitespace is removed

Input

<a>
  <b> x  y </b>
  <!-- c -->
</a>

Output

<a><b> x  y </b><!-- c --></a>

Line breaks and indentation between tags go. The spaces inside the b element are text content and stay, and so does the comment.

Each output was produced by running this tool on the input above it.

How it works

The XML is first checked for well-formedness. Then whitespace between a closing > and the next < is removed. Text content, including spaces inside elements, is not changed.

Details and limits

  • Only whitespace that lies between a > and the next < is removed. Whitespace inside tags, such as line breaks between attributes, is not.
  • Comments are kept. Remove them by hand if they should not ship.
  • In mixed content, a space between two inline elements (<b>a</b> <i>b</i>) is whitespace between tags and is removed too, which joins the words.
  • Input that is not valid XML stops the tool, and the status line shows where the problem is. The XML Validator page lists the usual causes.

Questions

Is my data uploaded when I use XML Minify?

No. The tool runs in your browser, so what you paste or open is processed on your own device and is not sent to a server.

What does XML Minify do?

XML Minify removes whitespace between tags after checking that the XML is well-formed, which puts an indented document on a single line. Whitespace inside text content is kept.

How does XML Minify work?

The XML is first checked for well-formedness. Then whitespace between a closing > and the next < is removed.

Are there any limits I should know about?

Only whitespace that lies between a > and the next < is removed. Whitespace inside tags, such as line breaks between attributes, is not. Comments are kept. Remove them by hand if they should not ship.

Is there a size limit?

There is no fixed size limit. Everything happens on your device, so very large inputs depend on its memory and can take longer on a phone than on a computer.

Does it work on phones, and is it free?

Yes. It works in any current browser on Android phones, iPhones, tablets and computers. It is free and needs no account or sign-up.