XML Minifier
Minify XML online by removing whitespace between tags, with an option to keep comments. Malformed XML is reported with its location.
Runs in your browser · Nothing uploadedFree · No sign-up
Something not working, or missing a feature? Send feedback
About the XML Minifier
The XML Minifier removes comments and whitespace between tags so XML payloads and feeds are as small as possible, while keeping text content intact.
Everything runs in your browser, so your input is never uploaded to a server.
How to use the XML Minifier
- Paste XML or open a file.
- Optionally keep comments.
- Copy or download the minified XML.
Example
Input
<?xml version="1.0"?>
<rss version="2.0">
<!-- generated nightly -->
<channel>
<item>
<title>Release 1.4</title>
<link>https://example.com/releases/1.4</link>
</item>
</channel>
</rss>Result
<?xml version="1.0"?><rss version="2.0"><channel><item><title>Release 1.4</title><link>https://example.com/releases/1.4</link></item></channel></rss>
The comment and the whitespace between tags are removed. Text such as "Release 1.4" is kept exactly.
Common mistakes
- Whitespace that matters. Some formats treat whitespace between elements as content, for example xml:space="preserve" sections. Check that such documents still read correctly after minifying.
- Removing needed comments. Comments are removed by default. Switch on "Keep comments" if a consumer reads them, such as licence headers.
- Invalid input. The minifier parses the XML first. Fix any reported error, often an unescaped & or a mismatched closing tag, before minifying.
Works well with the XML Minifier
- XML Formatter: make the XML readable again.
- XML Validator: find the line and column of a syntax error.
- XML to JSON: convert the payload to JSON.
Frequently asked questions
Is whitespace inside text removed?
No. Only whitespace between elements is removed; text content and mixed content are preserved.
Is the XML validated first?
Yes. Malformed XML is reported with its location instead of being minified.
Are attributes changed?
No. Attribute values and their quotes are kept; only whitespace between tags and, optionally, comments are removed.
Does it work for SVG?
Yes. SVG is XML, so icons and illustrations can be minified, although an SVG optimiser can also simplify paths.
Related tools
JSON Minifier
Minify JSON online by removing all unnecessary whitespace, and see how many bytes you saved. Invalid JSON is reported with its line and column.
HTML Minifier
Minify HTML online: remove comments and collapse whitespace while keeping pre, textarea, script and style blocks intact. See the size saved instantly.
CSS Minifier
Minify CSS online: strip comments, whitespace and redundant semicolons to shrink your stylesheet, and see the bytes saved. Runs in your browser.
JavaScript Minifier
Minify and mangle JavaScript online with Terser for smaller bundles. Supports modern ES syntax, with compress and mangle options and the size saved.
SQL Minifier
Compress SQL queries onto a single line online, removing comments and redundant whitespace. Useful for logs, config files and embedding SQL in code.
JSON Formatter
Format and beautify JSON with configurable indentation and optional key sorting. Errors are reported with exact line and column.