Skip to content
Webmaster Tools
JSON & dataXML Formatter

XML Formatter & Validator

Format and validate.

Paste or type XML
Output

        
Well-formed XML Invalid XML Runs in your browser

About the XML Formatter

This tool checks that an XML document is well-formed and re-indents it. It uses the browser's own XML parser (DOMParser with application/xml), so any error message comes straight from that parser. Format mode indents with 2 spaces, 4 spaces or tabs, puts each element on its own line and keeps short text-only elements on one line. Minify mode removes the whitespace between elements and drops comments. The XML declaration, CDATA sections, processing instructions and attributes are kept, and the status bar counts elements, attributes and nesting depth.

Everything runs locally, which makes it safe for SOAP responses, sitemaps, SAML assertions or config files that contain internal details.

How to use it

  1. Paste XML into the input pane, or click Load sample.
  2. Choose Format or Minify and an indent size.
  3. Check the status bar: Well-formed XML or Invalid XML with the parser's message.
  4. Copy the result or download it as formatted.xml.

Examples

Common questions

What is the difference between well-formed and valid XML?

Well-formed means the syntax is correct: one root element, properly nested and closed tags, quoted attributes, escaped & and <. Valid means it also matches a schema or DTD. This tool checks well-formedness only.

Why does &nbsp; cause an error?

XML predefines only five entities: &amp;, &lt;, &gt;, &quot; and &apos;. HTML entities like &nbsp; must be declared in a DTD or written as numeric references such as &#160;.

Does formatting change my data?

Whitespace-only text between elements is removed and text content is trimmed, which is harmless for most data formats. If whitespace in mixed content matters, keep the original.