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.

The minifying is done by the browser's DOMParser plus a short serializer in this page, so the file is not posted anywhere. Because the document has to parse first, a stray < or an unclosed element stops the job and you see the parser's complaint in red rather than a half-squashed file. Inputs above 5 MB are turned away with a hint to use a command-line tool.

How to Use the XML Minifier

The only decision you make here is whether comments survive. Everything else happens while you paste.

1

Paste, Upload, or Load Sample

Indented XML goes into the input editor, either pasted or opened from disk with Upload. Sample loads two subscriber records spread over 18 lines with a comment at the top, which is the kind of file where minifying pays off. This is what one record looks like once it has been squeezed:

<subscribers><subscriber><subscriberId>SUB-1001</subscriberId><plan>Unlimited 5G</plan><dataUsage>45.2</dataUsage></subscriber></subscribers>

With the Sample, the pill next to the output heading shows a saving of roughly a fifth of the bytes, almost all of it indentation plus the comment line. Clear empties both panels when you want to try another file.

2

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.

3

Download or Copy

Copy is the quick route into a request body or a test fixture; Download writes the same single line to minified.xml. Both are blocked while the output is empty, so a parse error never ends up in your file.

When You'd Actually Use This

Production Deployment

A SOAP envelope or a SAML assertion that you paste into a curl command or a unit test reads better as one line. Minify it here, keep the comments out of it, and the payload sits on a single line of your script without breaking the quoting.

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 &#233; 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

Minified XML is hard to read, so most people keep one of these open next to it, either to undo the squeeze or to check the file before shipping it: