XML Minifier
Minify XML online by removing layout whitespace and optionally comments to create a compact document after checking its syntax. Read more
Minify XML online
This XML minifier parses a document and removes indentation and line breaks used to lay out elements. It can also remove XML comments, producing a compact result for transport, storage, fixtures, or embedding in another text format.
Minification is not binary compression. HTTP gzip or Brotli may reduce transferred size further, and is a separate operation performed on the serialized XML bytes.
How to compact XML
- Paste a well-formed XML document into the input editor.
- Leave Remove Comments enabled unless comments must be retained.
- Click Minify.
- Correct any parsing error, then copy the compact output.
The tool validates well-formedness before returning a result. Removing comments permanently discards their contents from the output, so keep the original source when comments contain maintenance or licensing information.
Whitespace in XML can be data
Whitespace between elements is often only indentation, but it can be significant in text and mixed-content documents. The xml:space attribute and the rules of the receiving application can also affect whitespace handling.
Review and test minified documents that contain prose, inline markup, preformatted values, signatures, or systems that compare serialized XML rather than its parsed structure. The W3C XML specification describes XML’s syntax and whitespace handling.
XML minifier FAQ
Does minifying XML remove elements or attributes?
It is intended to remove layout whitespace and, when selected, comments. It does not deliberately remove elements or attributes, but whitespace-sensitive content must be reviewed.
Should XML comments be removed?
Remove them only when the recipient does not need them. Comments may contain documentation or operational information even though they are not element content.
How do I make compact XML readable again?
Use the XML Formatter to apply indentation. Use the XML Validator when you only need a well-formedness check.