LazyTools

🔒 Every tool runs in your browser, the files and values you enter are never uploaded to any server. How it works

📐 XML Formatter & Minifier

Paste messy or minified XML to format it with clean indentation, or minify it, all on your device.

pretty-printed, 2-space indent

Rate this tool:
Anonymous, no account, no identifier

How the xml formatter & minifier works

The formatter walks the XML tag by tag, indenting each element by its nesting depth and placing short text nodes inline with their element (<title>XML Basics</title>). Minify mode does the opposite. It removes the whitespace between tags to produce the smallest valid XML, while leaving text content untouched. It works on any well-formed XML, including SVG, RSS, sitemaps and config files. Indentation is purely structural: an element two levels deep gets two units of leading space, and its closing tag lines up with its opening tag. Only whitespace between elements is altered, the text inside an element, its attributes and their order are copied through byte-for-byte, so formatting can never change what the document means.

This is a formatter, not a converter, the structure and content are unchanged, only the whitespace differs. Pretty-printing makes machine-generated or minified XML readable for debugging; minifying trims transfer size. Everything runs in your browser, so the document never leaves your device.

Frequently asked questions

How do I format (beautify) XML?

Paste the XML or load a file and it's indented by nesting depth automatically. Choose a 2- or 4-space indent, then copy or download the result.

Can it minify XML too?

Yes, tick "Minify" and it removes the whitespace between tags to produce the smallest valid XML, without altering any text content.

Does it work on SVG and RSS?

Yes, SVG, RSS, Atom, sitemaps and config files are all XML, so the formatter handles them like any other well-formed XML document.

Does formatting change my data?

No, only the whitespace between elements changes. The elements, attributes and text content are preserved exactly.

Why does formatting fail on my file?

The formatter needs well-formed XML: every tag closed, a single root element, and reserved characters escaped (&amp; for &, &lt; for <). An unescaped ampersand in the middle of text is the most common cause, fix the well-formedness error the parser reports and re-run.

What is the point of minifying XML?

Removing the whitespace between tags shrinks the file, which trims bandwidth for XML sent over a network, SOAP requests, RSS feeds or a sitemap. The saving is only the indentation and line breaks, since text content is left intact, but on deeply nested documents that is still a meaningful reduction.

Is my XML uploaded?

No, formatting runs entirely in your browser and nothing is transmitted.

Related file converters