Skip to content
Tooletto

XML Minifier

A preset of XML Formatter

Collapse XML onto a single line by removing the whitespace between elements. Useful for embedding a document in a request body or a config value, where the indentation is dead weight.

  • Files never leave your device
  • Free, no signup
  • No watermarks
  • Works offline once loaded
Loading tool…

How to xml formatter

  1. 1

    Paste your XML

    A minified feed, a config file, a SOAP response — anything.

  2. 2

    Format or minify

    Indent for reading, or collapse for transport.

  3. 3

    Check for errors

    Mismatched and unclosed tags are named explicitly.

Where minified XML actually gets used

XML shows up in plenty of contexts where every byte of transfer size matters more than human readability — a SOAP request body sent repeatedly between services, a configuration value stored in an environment variable with a length limit, a feed fetched frequently by automated clients. Collapsing the whitespace between elements while carefully preserving CDATA sections, comments and attribute values exactly as written removes the formatting overhead without touching any of the data those special sections deliberately protect, which is the same safety guarantee the parser applies when formatting in the other direction.

Minifying does not touch the data, only the formatting

As with the formatter's parsing guarantees, minification here only ever removes whitespace between element tags — it does not reorder elements, rewrite attribute values, or alter anything a program parsing the resulting XML would actually read. A document minified this way and one formatted for readability represent exactly the same data to anything that consumes it programmatically; only their byte size and human legibility differ.

Whitespace inside an element is left alone, not just outside it

Whitespace between two sibling elements — indentation used purely for a human reader's benefit — is what gets removed. Whitespace that sits directly inside a text-bearing element as actual content, such as a deliberate space within a sentence stored as element text, is preserved rather than stripped, since XML has no general rule that whitespace inside element content is insignificant the way HTML often treats it. Getting this distinction right is part of why a purpose-built parser handles it correctly where a blanket "remove all whitespace" approach would corrupt genuine text content.

Frequently asked questions

Does it validate my XML?

It checks that tags are balanced and correctly nested, and names the offending tag when they are not. It does not validate against a DTD or XSD schema — that requires the schema itself and is a different job.

Are CDATA sections and comments preserved?

Exactly as written. The scanner recognises `<![CDATA[…]]>`, comments, processing instructions and DOCTYPE declarations before it looks for tags, so markup inside them is never mistaken for structure — which is precisely where regex-based formatters corrupt files.

What about attributes containing < or >?

Handled. The scanner tracks quoting while reading a tag, so an attribute like `note="a > b"` does not terminate the tag early. This is a common failure in simple formatters.

Can I use it for HTML?

For strict XHTML, yes. Real-world HTML has void elements like `<br>` and `<img>` that never close, plus optional closing tags, so the HTML formatter is the right tool for that — it uses an actual HTML parser.