← All tools
📰

XML Formatter & Validator

Paste XML to pretty-print it with your indent, minify it, or find exactly where it breaks. Comments, CDATA and mixed content are kept, and there’s an XPath tester. Nothing is uploaded.

Free · No sign-up

How to use XML Formatter & Validator

  1. 1. Paste your XML into the input box or pick an example.
  2. 2. Choose Format or Minify, the indent, and whether to keep comments and the XML declaration.
  3. 3. Read the status line: a green check means the XML is well-formed; otherwise you get the line, column and a pointer to the error.
  4. 4. Optionally run an XPath query, then copy or download the result.

Frequently asked questions

Is my XML uploaded anywhere?

No. Parsing, formatting and XPath all run in your browser with its built-in XML parser, so config files, feeds and API payloads never leave your device.

What does “well-formed” mean?

Well-formed XML has exactly one root element, every tag closed and correctly nested, quoted attribute values, no duplicate attributes, and & and < escaped as &amp; and &lt;. Any XML parser rejects a document that isn’t well-formed.

Does it validate against an XSD or DTD?

No. It checks well-formedness, which catches the vast majority of broken XML. Schema validation needs the XSD file and a schema processor; use your IDE or a command-line tool such as xmllint for that.

Will formatting change my data?

Only whitespace between tags changes. Elements that mix text and tags, anything under xml:space="preserve", CDATA sections, comments and processing instructions are kept exactly. Character references like &#169; are written as the character itself, which is equivalent XML.

Why do I get “Entity 'nbsp' not defined”?

&nbsp; and similar names are HTML entities. XML only predefines &amp;, &lt;, &gt;, &quot; and &apos;. Use a numeric reference such as &#160; instead, or declare the entity in a DTD.

How do I use XPath with namespaces?

Prefixes declared in the document work as written, for example //atom:entry. For a default namespace, like the one in a sitemap, use the prefix d: — for example //d:url/d:loc.

🛠️ Browse all text & developer guides and tools →