XML

XML Minifier

Strip insignificant whitespace to shrink XML for transport, storage or embedding.

Private by design — your data never leaves your device.
✓ Free forever✓ No sign-up✓ No ads✓ Works offline once loaded

XML Minifier

Strip insignificant whitespace to shrink XML for transport, storage or embedding.

Input

Your XML

Nothing is uploaded.

Output

Minified XML

Your result appears herePaste on the left and select “Minify XML”

Minifying XML removes the line breaks and indentation between elements, which typically cuts 20 to 40 per cent from a pretty-printed document. That matters when payloads travel over metered links, get embedded in another document, or are stored in a column with a length limit.

The document is parsed and re-serialised rather than processed with regular expressions, so whitespace inside text nodes, CDATA sections and attribute values is left exactly as it was. Only genuinely insignificant whitespace between elements is removed.

How it works

How to use the xml minifier

  1. 1

    Paste the formatted XML

    Paste or upload the document you want to compress.

  2. 2

    Minify

    The output pane shows the single-line result along with how many characters were saved.

  3. 3

    Copy or download

    Take the compact version straight to your clipboard, or download it as a file.

What is safe to remove, and what is not

Whitespace between elements — the newlines and indentation a formatter adds — carries no meaning in XML and is removed. Whitespace inside a text node does carry meaning and is preserved untouched, as is everything inside CDATA.

Elements marked with xml:space="preserve" and content inside CDATA blocks are left completely alone. If you need to compress further, gzip on the transport layer will typically do far more for XML than minification will, since XML compresses extremely well.

When minifying is worth it

Embedding XML into a JSON string, a database column or an environment variable, where line breaks are awkward to escape. Reducing SOAP request size on constrained or high-volume links. Producing a canonical single-line form for logging, so that one message occupies one log line.

It is generally not worth minifying XML that is only ever read by a human, or files under version control — a single-line document produces unreadable diffs.

Common questions

XML Minifier FAQ

Will minifying change what my XML means?

No. Only whitespace between elements is removed, which XML treats as insignificant. Text content, CDATA and attribute values are preserved byte for byte.

Can I reverse it?

Yes. Paste the minified output into the XML formatter to expand it again. The round trip is lossless apart from the original indentation choice.

How much smaller will my file get?

Typically 20 to 40 per cent for pretty-printed XML, depending on nesting depth. The tool reports the exact saving after each run.