EN

XML Formatter

Beautify & minify XML with attribute normalization

FAQ

Is CDATA preserved?

Yes, it is kept verbatim and not split or escaped as ordinary text.

Are comments removed?

Beautify keeps them; only minify strips comments and whitespace.

Does attribute order change?

Attributes are normalised. If their order carries meaning for you, verify the output manually.

About this tool

Beautify indents with 2 spaces and keeps <title>x</title> on one line when an element holds only a short piece of text, instead of forcing three lines. Recognition is token-based: CDATA → comments → processing instructions <? ?> → DOCTYPE (including an internal [ ] subset) → ordinary tags. Quotes inside a tag are respected, so a > appearing in an attribute value never truncates the tag — exactly where regex find-and-replace fails when reflowing XML.

Minify and beautify do not treat comments the same way: minify drops comments entirely (the usual byte-saving choice) while keeping CDATA, DOCTYPE and processing instructions; beautify preserves comments as written — whether a comment survives depends on which button you press.

Whitespace in text nodes is collapsed to a single space and trimmed. Harmless for data-only XML, but mixed content gets rewritten: in <p>hello <b>world</b></p> that space can disappear, so do not use this to reflow layout-sensitive XHTML. Non-ASCII tag names are left un-normalised while indentation still applies.

Attributes are normalised: identical name=value pairs are deduplicated, a single space separates them, and the original quote style is kept (single quotes are not silently turned into double quotes). Attributes with the same name but different values are both kept — that document was never valid XML. This tool only reflows: it does not check tag balance or validate. To find out whether a document is valid, parse it with the XML → JSON direction of the JSON ↔ XML tool, which uses the browser's native parser and reports syntax errors directly.