Formatters

Compact XML by removing whitespace

XML Minifier takes a pretty-printed document and returns one compact line. Whitespace-only text nodes (indentation and line breaks between tags) and XML comments are removed, while element text and attribute values stay byte for byte identical; interior spaces in text are preserved, and CDATA sections pass through untouched. Teams moving XML over HTTP or storing it in tight fields use it to shrink payloads, and the single-line output embeds in URLs and command lines.

How to use XML Minifier

  1. Open XML Minifier in the Toolbox101 app.
  2. Paste a pretty-printed XML document, such as the example below, into the Input box; the compact single-line version appears instantly.
  3. Scan the Output for what changed: indentation and comments are gone, while text content, attribute values, and CDATA stay intact.
  4. Click Copy to take the minified document, and keep a formatted copy around when you still need to read or debug it.

Worked example

XML Minifier returns the output below for this input.

Input

<config>
  <!-- device defaults -->
  <name>toolbox101</name>
  <features>
    <feature id="format">true</feature>
    <feature id="minify">true</feature>
  </features>
</config>

Output

<config><name>toolbox101</name><features><feature id="format">true</feature><feature id="minify">true</feature></features></config>

Check it yourself: open XML Minifier and enter the same input.

Frequently asked questions

What content does the XML minifier remove?

Two kinds of content: whitespace-only text nodes (the indentation and line breaks added between tags for readability) and XML comments, which the tool strips entirely. Tags themselves are emitted verbatim, including spacing inside them, so the single-line document keeps the structure and data of the original.

Does minifying change text content or CDATA?

No. Text inside an element is trimmed only at its edges, so runs of interior spaces survive (a b stays a b) and CDATA sections are copied verbatim, interior whitespace included. Attribute values are never touched, and quotes inside tags are tracked so a > inside a quoted attribute does not end the tag early.

Why minify XML before sending or storing it?

Pretty-printed XML can be several times larger than the data it carries, because indentation and line breaks are bytes too. Removing them shrinks HTTP payloads, database fields, and log lines, and a single-line document is easier to embed in URLs, queue messages, and command-line arguments.

Is minified XML harder to debug?

Yes: one long line is hard to scan by eye, so keep a formatted copy for reading. The XML Formatter tool here re-indents a minified document back into a readable layout, and the two round-trip. The minifier drops comments by design, so if your pipeline treats comments as data, keep them in the source.

Use XML Minifier now

Runs in your browser. Nothing you type is uploaded.