XML Minifier
Minify and compress XML
Input
Minified Output
What is XML Minifier?
Need a smaller XML file for a request body, a config bundle or storage? The minifier removes the indentation and line breaks between elements and, with Remove comments ticked, the comments too. The saving shows next to the output heading.
It is careful about what counts as "unnecessary". Only whitespace that contains a line break and sits between elements is dropped. Text values, CDATA sections and mixed content such as <p><b>Hello</b> <i>world</i></p> are left exactly as they were, and so is anything inside xml:space="preserve". The XML declaration (with its encoding) and the DOCTYPE are kept. The XML spec's white space rules are why we do not touch more than that.
Everything happens in your browser; the XML is not uploaded. If the input is not well-formed, the parser's error message is shown above the output instead of a result.
How to Use the XML Minifier
Follow these steps to minify your XML. Each step uses the actual buttons and panels on this page.
Paste, Upload, or Load Sample
Paste XML into the left Input panel, or click Upload to load a .xml file. Click Sample to load example telecomm XML. Example formatted input:
<subscribers><subscriber><subscriberId>SUB-1001</subscriberId><plan>Unlimited 5G</plan><dataUsage>45.2</dataUsage></subscriber></subscribers>Use Clear to start fresh. If the XML is not well-formed, the parser's error appears above the output panel.
View Minified Output
The right Minified Output panel updates as you type, with the bytes saved shown next to its heading. Untick Remove comments if your comments carry meaning (license headers, build markers) and should stay.
Download or Copy
Click Download to save minified.xml, or Copy to put it on your clipboard.
When You'd Actually Use This
Production Deployment
Minify XML config files before deploying to production. Smaller files mean faster loading times and reduced bandwidth usage.
API Optimization
Minify XML API responses to reduce payload size. Faster API calls and lower bandwidth costs, especially important for mobile apps or high-traffic APIs.
Storage Efficiency
Save storage space by minifying XML files. Great for archiving large amounts of XML data or when storage costs matter.
Network Transfer
Reduce transfer times by sending minified XML. Smaller files transfer faster, especially over slow connections or when dealing with large datasets.
Common Questions
Is my XML uploaded?
No. The whitespace and comments are stripped by JavaScript running on this page, so your XML stays on your own machine.
Does minification change my data?
No. Element names, attributes, text values and CDATA stay the same; only indentation between elements, and comments if you ask for that, are removed. A parser reading the minified file gets the same elements, attributes and text (the same information set, minus the ignorable whitespace). Entity references such as é come out as the character itself, which parsers treat identically.
How much smaller does it get?
It depends on how indented the file is and how many comments it has. The exact saving for your input is shown next to the output heading. Deeply nested, pretty-printed files shrink the most.
Can I format it back?
Yes. Paste the result into the XML Formatter to indent it again. Removed comments do not come back, so keep the original if you need them.
What about CDATA and mixed content?
Both are kept exactly. The minifier walks the parsed document and only skips whitespace-only text that contains a line break between elements, so whitespace inside CDATA or between words in mixed content is never touched.
Does it work with large files?
Up to 5 MB. Bigger inputs are refused to keep the page responsive; for those, a command-line tool such as xmllint with --noblanks does the job.
Other XML Tools You Might Need
Minification is just one XML task. Here are other tools that work well together: