Free Online XML Minifier

Paste XML below and click the Minify button to collapse it onto a single line, stripping whitespace between elements while keeping it valid XML.

Input Ready

Input statistics are available via the Stats button above this field.

Output

Output statistics are available via the Stats button above this field.

Results are provided for informational purposes only and may contain errors. Please verify important information independently. Use of this tool is at your own risk.

What the XML Minifier does

The XML Minifier removes comments and the whitespace between tags, putting the whole document on one line. The XML declaration, attributes, attribute order, CDATA sections and the short <tag/> form are left exactly as you wrote them.

The document is checked for well-formedness before anything is removed, so a broken file is reported with its line number instead of being turned into an even harder to read single line. The result is fully valid XML that every parser reads exactly like the original, just without indentation and comments, which makes it ideal for sending over a network or storing.

When to use it

  • Reducing the size of XML payloads sent to an API or stored in a database column.
  • Embedding an XML snippet in JSON, a string literal or an environment variable, where line breaks get in the way.
  • Stripping developer comments from a configuration file before shipping it.
  • Preparing XML for a single-line field in a CSV file, a spreadsheet cell or a message queue.

Worked example

Input

<config>
  <server host="localhost" port="8080"/>
  <!-- timeouts in seconds -->
  <timeout>30</timeout>
</config>

Output

<config><server host="localhost" port="8080"/><timeout>30</timeout></config>

Common questions about the XML Minifier

Is text inside elements changed?

No. Text content stays as it is; only whitespace that sits entirely between two tags is removed. Content in CDATA sections is never touched. Spaces inside attribute values, such as title="Hello world", are kept as well.

Are comments removed?

Yes, <!-- --> comments are dropped because they are not part of the data. Keep a formatted copy if the comments matter; the XML Formatter & Beautifier turns the minified file back into readable form.

How do I minify?

Paste the XML into the input box and click the Minify button in the toolbar above it. The minified XML replaces the input text, ready to copy.

Is this tool free?

Yes, it's free to use. No signup, no email required. Get results on this page.

How do I get my result?

Use the tool on this page. Your result appears here; no email delivery is required.