iLoveConverter
Categories 11 categories
Tool XML

Minify XML Online: Remove Only the Whitespace Between Tags

iLoveConverter Team 5 min read

On this page

Readability in XML has a price measured in bytes. Pretty-printed markup indents every level and breaks every line, and all of that whitespace travels with the document — into every request, every archive, every embed. The XML Minifier takes it out, with one carefully drawn boundary: it removes only the whitespace between tags, and never the text inside them. This guide explains what it deletes, what it protects, and why the conservative rule is a feature.

What the tool does

The XML Minifier deletes whitespace that sits between tags — the indentation and line breaks a pretty-printer added for human eyes. Its defining guarantee: only whitespace between tags is removed. The character data inside your elements is left exactly as it is, byte for byte.

That guarantee exists because XML treats text content as content. Whitespace added between markup is formatting; whitespace inside a text node is part of the value. The minifier draws the line exactly there: formatting whitespace goes, data whitespace stays.

For example:

<config>
  <timeout>30</timeout>
  <retries>3</retries>
</config>

becomes:

<config><timeout>30</timeout><retries>3</retries></config>

The values 30 and 3 are untouched — only the formatting whitespace between the tags disappeared. Like every tool on this site, it runs entirely in your browser via WebAssembly: your XML is never uploaded, and the tool is free with no watermark and no usage cap.

The judgment is deliberately plain: whitespace the pretty-printer added goes; whitespace that was already inside your text stays. In <timeout>30</timeout> the value 30 loses nothing, while the indent spaces before <timeout> are all reclaimed. That is the whole contract.

Step by step

  1. Open the tool. Load the XML minifier page in any modern browser.
    • Expected result: the page shows an input area ready for markup.
  2. Paste your XML. Pretty-printed, half-formatted, or mixed styles — any well-formed XML works.
    • Expected result: the markup appears in the input area.
  3. Run the minification.
    • Expected result: the output shows the tags run together without pretty-printing whitespace, while all text content reads identically to the input.
  4. Copy the result. Put the compact XML into delivery, archive, or embedding.

Parameters explained

There are no options — one conservative rule, applied deliberately. The scope:

  • Removed: newlines, tabs, and space runs that separate markup from markup — the whitespace a formatter introduced between one closing > and the next opening <.
  • Untouched: text inside elements, attribute values, comments, CDATA sections. None of these are whitespace-between-tags, so none are rewritten.

Why so conservative? Because XML vocabularies differ in how they treat whitespace, a minifier that removes only inter-tag whitespace stays out of trouble in the widest range of documents. When you need readability again, the XML beautifier re-indents the markup without touching anything else.

When to use it

  • Shipping XML over the network. API payloads and configuration delivery — every request pays for the bytes you send, and pretty-printing whitespace is pure cost.
  • Archiving many files. Bundles, exports, and long retention cycles — the savings compound across thousands of stored files.
  • Preparing XML for embedding. Single-line contexts such as generated code or script literals, where line breaks only get in the way. For the format’s rules on whitespace and structure, see our XML format guide.
  • Slimming machine-read payloads. Config delivery between services, scheduled XML snapshots — the reader is a program, not a person. Programs do not care about indentation; storage and bandwidth do.

Tips

  • Keep the pretty master. Minification does not remember your original indentation. Re-run the compact file through the XML beautifier whenever you need to read it again.
  • Whitespace-sensitive vocabularies. If your format assigns meaning to whitespace between elements — rare, but some inline documentation formats do — test on a small sample first. The tool removes only inter-tag whitespace, so your text stays as-is; what the consumer does with what remains is defined by that consumer.
  • Minify last. Edit in pretty form and minify at the moment of delivery, or you will be reviewing a one-liner halfway through a change.

Tool vs desktop software

Command-line XML utilities such as xmllint offer whitespace-stripping modes, and XML editors do the same from a menu. Desktop and CLI win for automation — stripping hundreds of files inside a build. The web tool wins for quick one-offs: nothing to install, any browser, runs locally as WebAssembly so confidential markup stays on your machine, free with no watermark and no usage cap.

One behavioral difference is worth knowing: desktop tools sometimes treat text whitespace differently depending on options, while this tool’s behavior is fixed — same input, same output, every time. That predictability is what you want when the step goes into a team runbook.

FAQ

Will it change the text inside my elements?

No. Only whitespace between tags is removed. Character data is preserved byte for byte — the values in the minified output are exactly the values you put in. If you want extra certainty on a critical file, parse the minified output once and compare a few text values before shipping.

Does it remove comments or CDATA sections?

No. Comments and CDATA are content, not whitespace. Minification removes whitespace only, so both survive untouched — including any spaces inside them.

Is the output still well-formed XML?

Yes. The XML grammar does not require whitespace between elements, so the document structure parses identically to the input. Only the inter-tag whitespace is gone.

What about mixed content, where text and tags interleave?

The rule is fixed and conservative: whitespace between tags goes, text content stays. If your document interleaves text and inline tags tightly, run a small sample first and check that whatever consumes it reads the result as intended.

How do I get readable XML back?

Feed the compact file to the XML beautifier: it re-indents the markup and changes nothing else. Your original spacing is not restored bit-for-bit, but the structure becomes fully readable again.

Is my XML uploaded to a server?

No. Minification runs locally in your browser via WebAssembly. Nothing leaves your machine, and nothing is stored after you close the tab.

Try it yourself — free, right in your browser

Everything mentioned in this guide runs locally on this site: no upload, no watermark, no sign-up.

Format deep-dives: XML (.xml)