XML Minifier

Remove the whitespace between XML elements, and optionally comments, to get a compact document. Text inside elements and attribute values is left alone.

Use the tool

Why this tool exists

Indented XML is easy to read but larger than it needs to be. When you embed XML in a message, store it in a database column, or send it through a service with a size limit, the formatting is dead weight.

The minifier parses the document and writes it back without the layout whitespace between elements, so the structure and the content stay the same. Comments are dropped by default and can be kept with one tick. Spaces inside text, such as in a name with two words, are not touched. If the XML is broken you get an error instead of a mangled result. Minifying happens in your browser and nothing is uploaded.

How to use it

  1. Paste your XML into the input box.
  2. Tick Keep comments only if you need them in the output.
  3. Read the compact single-line result.
  4. Copy it into your message, field or file.

Frequently asked questions

Will minifying change how my XML is read?

For data-style XML, no. Only layout whitespace between elements is removed. Text inside elements keeps its spaces. If your document relies on whitespace between inline elements, check the result.

Does it remove the XML declaration?

No. The declaration and processing instructions stay in place. Only whitespace between elements and, by default, comments are removed.

How much smaller will the file get?

It depends on how deeply the original was indented. Heavily indented documents often lose a large share of their size, while already compact ones change little.

How do I make it readable again?

Run the minified output through the XML Formatter. It restores indentation and line breaks so the structure is easy to read again, with the same content.