XML Minifier

Formatters

How to use the XML Minifier

Minify XML in three steps:

1

Paste your XML

Paste formatted or indented XML into the input box, or upload a .xml file. The input is parsed by your browser's DOMParser before compression.

2

Choose options

Toggle 'Remove Comments' on or off. When enabled, all <!-- XML comments --> are stripped from the output. When disabled, comments are preserved in compact inline form.

3

Minify and copy

Click Minify XML. Review the size reduction stats (original size, minified size, bytes saved, and percentage reduction), then copy or download the result.


When to use this tool

Use the XML minifier to reduce file size and payload overhead:

  • Minimising XML API response payloads before serving them over bandwidth-limited connections
  • Compressing Android resource XML files (layouts, strings, drawables) to reduce APK size
  • Reducing SVG file sizes for web use by stripping editor-generated whitespace and comments
  • Minifying SOAP request bodies before transmission to reduce HTTP payload overhead
  • Compressing XML configuration files for embedding in binary distributions or containers
  • Stripping development comments from XML configuration before production deployment
  • Preparing XML data files for embedding in JSON payloads where line breaks cause parse errors

Frequently asked questions

Q:Is the minified XML still valid and semantically identical?
Yes — the minifier uses the browser's DOMParser to parse the XML into a DOM tree before serializing it in compact form. This guarantees the element structure, attribute values, text content, namespace declarations, and processing instructions are all preserved exactly. Only insignificant inter-element whitespace is removed.
Q:What is 'insignificant whitespace' in XML?
Whitespace between elements — the spaces, tabs, and newlines used purely for indentation and readability — is considered insignificant and does not affect the document's meaning. Whitespace inside text content nodes (e.g. the text inside a <description> element) is significant and is never touched by the minifier.
Q:Can I minify XML without removing comments?
Yes — the 'Remove Comments' toggle is off by default, so comments are preserved in the minified output in their compact inline form. Enable the toggle only if you specifically want comments stripped.
Q:Does minifying SVG affect how it renders?
In most cases, no — SVG rendering is based on element content, not whitespace. However, whitespace in SVG <text> and <tspan> elements is significant for text layout, and the minifier preserves text node content. Inspect SVG text rendering after minification to confirm.
Q:How much compression can I expect?
For heavily indented XML with 4-space indentation, minification typically reduces file size by 30–60%. The actual reduction depends on nesting depth, number of elements, and how much of the file is whitespace. The stats panel shows precise figures for your specific file.
Q:Does this tool send my XML to a server?
No — minification runs entirely in your browser using the DOMParser API and JavaScript DOM serialization. Your XML never leaves your device, making it safe to minify XML containing sensitive configuration values, connection strings, or internal schema names.