How to minify an XML document
Minifying XML removes comments and the whitespace between elements, producing a compact document that parses identically to the indented original. It is used to shrink payloads and to fit a document into a single-line field.
The transform runs in your browser as a text pass rather than a full XML parse. That makes it fast and means it cannot recognise the places where whitespace is meaningful, so it suits element-only documents and not prose.
- Paste the XML document into the input box.
- Read the compacted output, which has comments and inter-element whitespace removed.
- Check any part of the document that mixes text with tags, because the spaces separating them are removed and the words will run together.
- Confirm that no CDATA sections were damaged, since their contents are collapsed like everything else.
- Prefer enabling gzip on your server if the goal is transfer size, since it saves several times more than minifying does.