Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

XML Compressor & Whitespace Remover

Paste XML and instantly remove unnecessary whitespace, comments, and formatting to reduce file size

Your files never leave your browser
Input0 chars, 0 lines
Output0 chars, 0 lines
Ready·

Paste any XML — config files, SOAP payloads, SVGs, Maven POMs — and strip out whitespace, comments, and blank lines in one click. The output is the same document, just without formatting characters that inflate file size by 30-50%.

Handy when you need smaller payloads for API calls, leaner configs for CI pipelines, or cleaner SVGs for inline embedding. And everything runs in your browser. Nothing gets uploaded.

How It Works

Paste XML
→
Strip Whitespace & Comments
→
Minified Output

The tool parses your XML character by character. It collapses all whitespace between tags into nothing, removes <!-- comment --> blocks entirely, and trims extra spaces inside text nodes down to a single space. CDATA sections stay untouched — those are literal content and shouldn't be modified. If you check "Remove PIs," it also strips processing instructions like <?xml version="1.0"?>.

Examples

Cleaning Up a Config File

You exported an app config and it's full of indentation and developer comments.

INPUT
<config> <!-- Database settings --> <database> <host>db.prod.local</host> <port>5432</port> </database> </config>
OUTPUT
<config><database><host>db.prod.local</host><port>5432</port></database></config>

Shrinking a SOAP Request Body

SOAP envelopes from code generators tend to be heavily indented. Compressing before sending cuts the payload size by 30-40%.

INPUT
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetPrice> <Item>Widget-A</Item> </GetPrice> </soap:Body> </soap:Envelope>
OUTPUT
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetPrice><Item>Widget-A</Item></GetPrice></soap:Body></soap:Envelope>

Stripping Comments and PIs from an SVG

SVG files exported from Illustrator or Inkscape often carry XML declarations, editor comments, and metadata. Remove all of it before embedding in HTML.

INPUT
<?xml version="1.0" encoding="UTF-8"?> <!-- Created with Inkscape --> <svg width="100" height="100"> <circle cx="50" cy="50" r="40" /> </svg>
OUTPUT
<svg width="100" height="100"><circle cx="50" cy="50" r="40"/></svg>

Who Uses This

👨‍💻 Backend Developers

Minify XML payloads before sending them through REST or SOAP endpoints to cut response times.

🔧 DevOps Engineers

Compress Maven POM files, Spring configs, and deployment descriptors before baking them into container images.

🎨 Web Designers

Clean up SVG files exported from design tools so they're smaller when inlined in HTML pages.

📊 Data Analysts

Shrink large XML data exports before archiving or transferring them between systems.

Common Mistakes

Compressing XML that has significant whitespace

Some XML schemas treat whitespace inside text nodes as meaningful — poetry markup, code listings, or pre-formatted content. Compressing those will collapse spaces and break the output. Check whether your schema uses xml:space="preserve" before running the compressor.

Removing the XML declaration when it's required

Checking "Remove PIs" strips <?xml version="1.0" encoding="UTF-8"?>. That's fine for embedding in HTML, but some XML parsers need it — especially when the encoding isn't UTF-8. If your system throws encoding errors after compression, uncheck that option.

Assuming compression equals gzip

This tool does minification, not binary compression. It removes formatting characters. For maximum size reduction on large files, minify first here, then apply gzip or Brotli on your server. The two approaches stack — you'll typically save 30-40% from minification and another 60-70% from gzip on top of that.

Technical Details

Frequently Asked Questions

What's the difference between XML compression and XML minification?

People use the terms interchangeably, but technically "minification" means removing whitespace, comments, and formatting to reduce character count. "Compression" usually refers to binary encoding like gzip. This tool does minification. For the best results, minify your XML here and then serve it with gzip compression on your web server.

Does compressing XML change any data or break the document?

No. The compressor only removes characters that don't affect the XML's meaning — whitespace between tags, comment blocks, and optional processing instructions. Every element, attribute, and text value stays identical. The compressed output is semantically the same document.

How much smaller will my XML file get?

Depends on how formatted the original is. A heavily indented file with lots of comments can shrink 30-50%. Something already fairly compact might only drop 5-10%. The tool shows you the exact byte counts and percentage right after you compress.

Is it safe to paste sensitive XML data into this tool?

Yes. Everything happens in your browser with JavaScript. Your XML is never sent to any server, never stored, and never logged. You can turn off your internet connection and the tool still works — that's how you know nothing leaves your machine.

What happens to CDATA sections during compression?

They're left completely alone. CDATA blocks contain literal content that's meant to be read as-is, so the compressor skips over them. Whatever was inside your <![CDATA[...]]> tags before compression will be exactly the same after.

Share: