100% local — your data never leaves your browser

XML Minifier — Smaller, and Says the Same

Strip the indentation from XML. Text spacing, attribute values, comments and the prolog stay, so the document shrinks and still means what it meant.

Instant Private Zero cookies

XML input

XML output

What this tool does

It removes the indentation, and only the indentation.

<library>
  <book>
    <title>Dune</title>
  </book>
</library>

becomes <library><book><title>Dune</title></book></library>.

What it deliberately keeps

Spaces inside text. <p>Hello <b>world</b> again</p> comes back unchanged. In XML those spaces are character data — there is no whitespace collapsing as in HTML — and removing them glues words together.

Attribute values. t=" keep " stays as written. Whitespace in an attribute value is only normalised for non-CDATA types, which a DTD alone can declare; without one, every space is significant.

A lone space between two elements on the same line. <b>x</b> <i>y</i> keeps its space. Nothing in the document says it is negligible.

Comments, CDATA sections, the prolog. The declaration comes back with the version, encoding and standalone you wrote, the DOCTYPE survives, and a <?xml-stylesheet?> instruction stays where it was.

xml:space="preserve" suspends the whole operation for the element that carries it.

What counts as indentation

A text node that is entirely blank, that contains a line break, and that sits in an element with no significant text of its own. That is the definition, and it is deliberately narrow: everything outside it is content until proven otherwise.

How much smaller

Less than you might hope, and that is honest rather than disappointing. Indentation is usually a few percent of an XML document; the tags themselves are the bulk, and shortening those would mean changing the document.

If the goal is transfer size, compression does far more: gzip finds the repetition in tag names that no minifier can remove. Minify for a file you will store or embed, not for the wire.

Private by design

Everything runs locally in your browser with JavaScript. Your data is never uploaded, which makes the tool safe for sensitive content, and it keeps working offline.

Frequently asked questions

Why is my output barely smaller?
Because XML minification is indentation removal and little more. There is no shortening of names, no dropping of quotes, no whitespace collapsing inside text — those would change the document. If you serve XML over HTTP, gzip or brotli already removes far more than this does, and without touching the content.
Why did <b/> come back as <b></b>?
The two are identical in XML, and the longer one is the safe direction. A document that is XHTML and gets served to a browser as HTML breaks on a self-closing `<div/>` — the browser reads it as an opening tag and swallows the rest of the page. Two characters is a small price for that not happening.
Are comments removed?
No. A comment in an XML document is often a licence header, a schema note or an instruction to the next reader, and nothing in the document says which. Removing them would be a judgement this tool is not in a position to make. Delete the ones you do not want before minifying.

Related converters