XML formatter

Beautify or minify XML and see exactly where it is not well-formed.

Indent
Input
Output

Output will appear here

What this XML formatter does

XML (Extensible Markup Language) stores structured data in nested tags, and it is still the backbone of countless configuration files, document formats (like Office and SVG files), SOAP web services and data feeds. Like any markup, it is far easier to read when it is indented. This tool beautifies XML — putting each element on its own line with consistent indentation — or minifies it onto a single line, and at the same time checks that the document is well-formed.

What "well-formed" means

Well-formedness is the baseline set of rules every XML document must follow, separate from whether it matches a particular schema. A well-formed document has:

  • Every opening tag matched by a closing tag, or written as a self-closing tag.
  • Tags nested properly, so they never overlap (an inner tag must close before its outer tag).
  • All attribute values wrapped in quotes.
  • Special characters such as < and & escaped as entities (&lt; and &amp;) inside text.

When any of these rules is broken, this tool reports the exact line and column of the first problem — a mismatched or unclosed tag, an unterminated comment, or a stray < in text — so you can fix it quickly instead of hunting through the whole document.

Beautify vs. minify

  • Beautify when you need to read, diff or debug XML: indentation reveals the document structure and makes nesting obvious. Choose 2 spaces, 4 spaces or a tab to match your style.
  • Minify when you need to transmit or store XML compactly: whitespace-only gaps between elements are removed and the document collapses to a single line, without changing its meaning.

Comments, CDATA sections, processing instructions and the XML declaration are all preserved through both operations, so nothing meaningful is lost when you reformat.

XML compared with JSON

JSON has become the default for web APIs because it is lighter and maps directly onto the data types of most programming languages. XML remains a better fit where documents need mixed content (text with inline markup), rich metadata via attributes, comments, namespaces, or validation against a formal schema. Many systems — enterprise integrations, publishing pipelines, office documents — are built on XML and will be for a long time, which is why comfortable, reliable formatting still matters.

Frequently asked questions

What does "well-formed" mean?
Well-formed XML has every tag properly closed and nested, attribute values quoted, and special characters escaped. This tool checks those rules and points to the first place they break.
Is my XML sent to a server?
No. Formatting and validation happen entirely in your browser. Nothing you paste ever leaves your device.
Does it validate against a schema (DTD or XSD)?
No. It checks well-formedness — the structural rules every XML document must follow — but not whether the document matches a specific DTD or XSD schema, which is a separate step.
Are comments and CDATA preserved?
Yes. Comments, CDATA sections, processing instructions and the XML declaration are all kept intact when you beautify or minify.
Why does it report an error on HTML?
HTML is more lenient than XML — it allows unclosed tags like <br> and unquoted attributes. Those are not well-formed XML, so they are reported. Only XHTML-style, strictly closed markup will pass.
Does formatting change my data?
No. Beautifying and minifying only change whitespace between elements. Element names, attributes, text content and structure are unchanged.