XML Minifier
Compress an XML document by removing the whitespace between elements and, optionally, comments.
Processed locally in your browser· Your data stays in your browser.
What is XML Minifier?
Pretty-printed XML carries a lot of whitespace that only exists for humans. Minifying removes the indentation and line breaks between elements so that the document is smaller and fits on one line, for example when it must be stored in a database field, embedded in a string or sent in a size-limited request.
The tool checks that the XML is well-formed, then removes whitespace-only text between elements and (by default) comments. Text inside elements, CDATA sections, attributes, the XML declaration and mixed content such as <p>Hi <i>you</i></p> are preserved, and a report shows the size before and after.
How does it work?
- Paste your XML in the input box.
- Leave “Keep comments” off to strip them, or turn it on to preserve them.
- Read the size report and copy the one-line result.
- Download minified.xml if you need a file.
Common use cases
- Reducing the size of XML stored in a database column or a cache.
- Embedding an XML snippet in a JSON string or an HTTP header value.
- Shrinking SVG-like or configuration XML before shipping it.
- Removing developer comments from an XML file before publishing.
Examples
Try this input in the tool above:
<?xml version="1.0"?>
<config>
<!-- server settings -->
<server host="localhost" port="8080">
<name>Main</name>
<tags>
<tag>a</tag>
<tag>b</tag>
</tags>
</server>
</config><?xml version="1.0"?><config><server host="localhost" port="8080"><name>Main</name><tags><tag>a</tag><tag>b</tag></tags></server></config>
Privacy
XML Minifier runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.
Limitations
Whitespace inside text content is preserved, so minified output is not always the absolute smallest. Documents that rely on xml:space="preserve" should be checked after minification.
Frequently asked questions
Can minifying change the meaning of my XML?
For data-oriented XML no: only formatting whitespace between elements is removed. For document-oriented XML with mixed content, text and inline elements are preserved exactly.
Are comments removed?
Yes by default, because comments are not data. Enable “Keep comments” to preserve them.
Does it work with namespaces and CDATA?
Yes. Prefixes, xmlns attributes and CDATA sections are kept verbatim.
Related tools
XML Formatter & Beautifier
Turn compressed or messy XML into a cleanly indented document that is easy to read and review.
JSON & Data
XML Validator
Find out whether your XML is well-formed and see precisely where it breaks.
JSON & Data
XML to JSON Converter
Turn an XML document into JSON, keeping attributes, repeated elements and text content in a predictable structure.
JSON & Data
HTML Minifier
Shrink your HTML with a conservative minifier that leaves <pre>, <textarea> and <script> content untouched.
Developer Tools
JSON Minifier
Compress a JSON document to one compact line and see how many bytes you saved.
JSON & Data
XML Escape
Make any text safe to place inside an XML element or attribute value.
JSON & Data