Shipping an AI app or agent? Security review in 1 working day: $149 / ₹13,900. Request a review →
AI Review Ready
Home / Free tools / XML formatter
Free tool · runs in your browser

XML formatter and validator

Paste XML to indent it, minify it, or find out why it isn't well-formed. Runs entirely in your browser.

Well-formed XML: the rules that break most often

From the W3C XML 1.0 specification:

  • Exactly one root element wraps everything.
  • Every start tag has a matching end tag (or is self-closing, <br/>), and tags close in the right order.
  • Tag names are case-sensitive: <Item>…</item> is an error.
  • Attribute values are quoted, and an attribute appears only once per element.
  • & and < inside text must be written as &amp; and &lt; (or wrapped in CDATA).
  • The <?xml …?> declaration, if present, must be the very first thing in the file.

Well-formed is not the same as valid

This tool checks well-formedness (the syntax). Checking against a schema (XSD or DTD) is a separate step.

Formatting and whitespace

Pretty-printing removes whitespace-only text between elements and trims text content. That is fine for data files and configs, but in mixed content (like XHTML paragraphs) whitespace can matter, so keep the original if exact spacing is important.

Sources