Minify XML
Paste any XML document and get a compact version, with the whitespace between elements removed, ready for network transport, embedding, or storage. The minifier parses the input with DOMParser and re-emits it without indentation.
Input XML
Minified XML
ACTION
Runs entirely in your browser
How it works
The tool uses the browser's native DOMParser to build an in-memory tree from your XML, then walks the tree to emit either an indented or minified result. Validation reports the parser's error message when a document cannot be parsed.
Processing runs in your browser
All parsing and formatting happens locally in your browser tab. Our servers are not involved at any point.
Frequently asked questions
- Does minifying remove comments?
- Comments, processing instructions and CDATA sections are kept in the output. The minifier removes only the whitespace between elements, so a comment that documents a setting is still there after minifying. Delete comments by hand first if you need the smallest possible file.
- Is whitespace inside text changed?
- Whitespace inside text is kept, including the spaces in <name> Ada </name>, and mixed content such as <p>Hello <b>world</b></p> is left untouched. Only whitespace-only text between child elements is removed, along with the line break after the XML declaration.
- Why minify XML?
- Minified XML payloads are smaller, which reduces bandwidth on the wire and storage cost when XML is embedded in databases, message queues, or static assets.
- Does minification change the document's meaning?
- Minification only removes inter-element whitespace. Element names, attributes, text content, CDATA blocks, and the overall structure remain identical. Entities declared inside the DOCTYPE are written out as their expanded text.
- Can minified XML be parsed by other tools?
- Yes. Minified XML is fully valid and parses correctly in every standard XML library.
- Will the minifier reject invalid XML?
- Yes. If DOMParser reports a parser error, the tool surfaces it instead of producing a result.
Last reviewed September 30, 2026
Other pages for this tool
Related tools
YAML formatter
Format, validate, and convert YAML. Compatible with Kubernetes, CI configs, and OpenAPI files.
JSON formatter
Pretty-print, minify, validate, and sort JSON keys. Instant output.
HTML entity encoder
Encode special characters to HTML entities and decode them back. Instant, in your browser.
CSV ↔ JSON
Convert CSV to JSON and JSON back to CSV. Handles quoted fields and downloads.
- Background reading: Complete guide to developer tools