XML Minifier
Shrink XML by stripping whitespace and comments.
How to use
- 1 Paste your formatted XML into the input box.
- 2 Optionally tick Remove comments or Collapse text whitespace.
- 3 Read the minified output and the characters-saved summary.
- 4 Copy the compact XML for use in your app or payload.
About XML Minifier
The XML Minifier compresses an XML document down to its smallest well-formed form by removing the insignificant whitespace that pretty-printing adds.
When you indent and line-break XML for readability, every level of nesting introduces spaces, tabs and newlines between the tags.
Those characters are meaningless to a parser but they inflate file size, which matters for SOAP payloads, RSS feeds, SVG assets, sitemaps, configuration files and any XML travelling over the wire.
This tool walks the document, drops the whitespace sitting between elements, and re-emits a single compact line that parses to exactly the same tree.
Crucially, it is careful about what it keeps.
Text inside an element, attribute values and CDATA sections are preserved byte-for-byte by default, because collapsing them could silently change your data.
If you do want tighter output you can opt in to collapsing runs of whitespace inside text nodes, and you can choose to strip comments entirely.
The parser also checks structural well-formedness as it goes: it reports mismatched tags, unclosed elements, multiple roots and unterminated comments with a clear message instead of producing broken output.
Everything runs locally in your browser.
Your XML is never uploaded, logged or stored, so it is safe for private or proprietary documents, and the tool keeps working offline once the page has loaded.
FAQ
Does minifying change what my XML means?
No. Only whitespace between elements is removed by default. Text content, attribute values and CDATA are preserved exactly, so the document parses to the same tree.
Will it catch broken XML?
Yes. It validates well-formedness as it parses and reports mismatched tags, unclosed elements, multiple root elements and unterminated comments with a specific message.
Is my XML uploaded anywhere?
No. Minification happens entirely in your browser using JavaScript. Nothing is sent to a server, so it is safe for confidential documents.