XML Minifier
Strip inter-element whitespace, comments and optional declarations, with the byte savings shown.
What is XML Minifier?
An XML minifier. It removes only the parts of a document that XML itself calls insignificant: indentation between elements, comments and redundant declarations. Text a consumer would notice is never touched.
How it works
The tree is printed without indentation, dropping whitespace-only text nodes, comments, processing instructions (the XML declaration excepted), empty attributes and unused namespace declarations, depending on the options. Each removal is counted and reported next to the original and final byte counts, so you can see whether the change is worth it before shipping it. Mixed-content and xml:space="preserve" subtrees are excluded from whitespace removal.
- Paste the document. Drop in XML, a schema, a feed or an XPath expression. Everything is parsed in the page: no upload, no server round trip, and the tools keep working with the network switched off.
- Set the options that match your document. Indent unit, whether to keep comments, which dialect, which output method. The defaults are the safe ones — nothing that changes meaning is enabled for you.
- Read the result, then copy or download it. Results appear as you type, copy straight to the clipboard, and download with a sensible filename (.xml, .xsd, .csv). Reset returns every field to its default.
Examples
A minified document from an API response
Paste one line of XML and the Formatter indents it, wraps long start tags one attribute per line and normalises empty elements — without touching text inside mixed content.
An XPath that works in Chrome and not in your servlet
The XPath Tester evaluates against a real tree and reports the axis or function it cannot support, instead of returning zero nodes and letting you guess why.
A document that will not parse
The Validator gives line and column for every mismatched tag, stray ampersand and duplicate attribute, with the reason in words: which open element was expected, which was found.
A schema that only half matches your data
The XSD Validator marks each violation with the path of the offending node, and the Schema Generator goes the other way — inferring a starting-point XSD from real documents.
Common mistakes
Assuming a pretty-printer cannot change meaning
Whitespace between elements is often insignificant, but inside mixed content it is not: `<p>Hello <b>world</b></p>` must stay on one line. Formatting here re-indents element-only content and leaves mixed content alone.
Treating a validation pass as proof of interoperability
The DTD and XSD validators implement honest subsets. A document reported valid here can still be rejected by a full validator that understands identity constraints, substitution groups or XSD 1.1 assertions — each page lists what it does not cover.
Reading the whole document because the parser did
A DOCTYPE is not inert. If your parser resolves external entities, pasting an untrusted document is enough to read a file or call an internal URL. The XXE Risk Checker shows what a document asks for; the fix is in the parser configuration.
Forgetting that attributes and elements are not interchangeable
`<id>1</id>` and `id="1"` mean different things to every schema and every XPath. When converting to CSV or YAML the distinction is preserved (`@id`), because flattening it away is the change that costs an afternoon later.
Frequently asked questions
How much does minifying actually save?
On a hand-indented configuration file or a SOAP response, typically 20–40% — the bytes are almost entirely indentation. On a machine-generated document that is already one line it saves nothing, which is why the tool reports the real numbers instead of a promise.
Is it safe to minify before signing or hashing?
No — do it the other way round. Canonical XML and XML signatures are computed over an exact byte sequence, so whitespace removal after signing invalidates the signature, and removing it before signing changes what you signed. Minify first, then sign.
Which namespace declarations get dropped?
Only declarations nothing references: no element or attribute in scope uses the prefix, and the default namespace is never removed because that would change how unprefixed elements are interpreted.