Dev tools

Minify XML

minify xml. Strips comments and collapses whitespace via regex, not a real parser (might mishandle markup-like sequences inside string/attribute values). JS minification isn't offered here: doing it safely needs a real parser this task can't add. Runs on your device.

Runs on your device. The file is never uploaded.

Minify XML shrinks a document by deleting its comments and the indentation between elements, and prints the result as text. It runs the same markup pass as Minify HTML, so either file type gets an identical result. Nothing parses the XML and nothing checks a schema, so a malformed document comes back minified and still malformed.

Input

Questions

What does it do to my XML?

Removes comments between <!-- and -->, deletes whitespace between tags, collapses runs of spaces and tabs to a single space, and removes newlines along with the indentation after them. Element names, attributes and text values are left alone, so the structure of the document is unchanged.

Does it preserve significant whitespace?

No. Whitespace inside text nodes is collapsed and whitespace between tags is deleted, so a document where spacing carries meaning, or one relying on xml:space="preserve", will not come through intact. For mixed content such as XHTML paragraphs, read the output before you rely on it.

Are the declaration and doctype kept?

Yes. Only comment blocks are removed, so the XML declaration, the doctype and any processing instructions pass through as ordinary text. CDATA sections survive as text too, though whitespace inside them is collapsed like everywhere else, since the passes make no exception for them.

Does it validate the XML?

No. There is no parser and no schema check, so a malformed document is minified the same as a valid one and comes back still malformed. If you need to know whether it parses, run it through a validator first; this tool only makes it smaller.

Is it the same as the HTML minifier?

It runs exactly the same routine. Both share one markup pass, so a file either one accepts gets an identical result from both. The separate entries exist because people look for one name or the other, not because the behavior differs.

How many files can I drop in?

As many as you like. Each is minified separately and the results are printed as text one after another, in the order you dropped them. There are no options to set, and nothing is uploaded: the files are read and rewritten inside a Web Worker in this tab.

Related Dev tools