Skip to content
AZ Tools

XML Formatter & Minifier

Beautify XML with clean indentation or minify it to one line, in your browser.

How to use

  1. Paste your XML into the input box.
  2. Choose Beautify (and an indent size) or Minify.
  3. Copy the formatted XML from the output box.

About this tool

Show

Paste XML and reformat it instantly — pretty-print it with two spaces, four spaces or tabs, or minify it down to a single line. The document goes through the browser's real XML parser rather than a regular expression, which matters in both directions: a bare ampersand, a mismatched or unclosed tag, or a closing tag whose case does not match is reported as an error instead of being reformatted into something that still will not parse. XML is strict where HTML forgives, so an unclosed br is a genuine error here, not an oversight. Comments, CDATA sections and processing instructions are carried through untouched, and namespace prefixes stay exactly as you wrote them. Everything runs locally in your browser — nothing is uploaded.

Frequently asked questions

What does beautify do?

It re-indents the document by nesting depth so the structure is easy to read, putting each element on its own line. Whitespace between elements is normalized.

What does minify do?

It removes the whitespace between elements and the indentation, collapsing the document to a single line — useful for compact storage or transport.

Does it keep comments and CDATA?

Yes. Comments, CDATA sections and processing instructions are preserved, and special characters in text and attributes are properly escaped.

What if my XML is invalid?

The document is parsed with the browser's XML parser. If it isn't well-formed, an error message is shown instead of broken output.

Is reformatting XML always safe?

Not for every document. Indentation adds whitespace between elements, which is invisible in most formats but is data in a few: mixed content where text sits alongside child elements, and any element carrying xml:space="preserve". Reformat configuration and data files freely; be careful with documents that hold prose.

Why does my HTML fail to parse here?

Because this is an XML parser and HTML is not XML. Unclosed tags like br and img, unquoted attribute values and named entities beyond the five XML defines are all legal HTML and all fatal errors here. That strictness is the point — it catches the mistakes an HTML parser would silently repair.

Related tools