XML Formatter & Validator

Pretty-print, indent and validate XML documents.

What Does the XML Formatter Do?

The XML Formatter validates, pretty-prints and minifies XML documents. Paste raw XML — a SOAP payload, an RSS feed, a sitemap, an Android layout, a configuration file — and get consistently indented, readable markup, or strip all inter-element whitespace for the smallest possible payload. If the document is not well-formed, the browser's strict XML parser pinpoints the problem for you.

The formatter preserves everything meaningful: attributes, comments, CDATA sections and the XML declaration. Elements that contain only text are kept on one line for readability, while nested structures are indented two spaces per level.

How to Use the XML Formatter

  1. Paste your XML into the input box.
  2. Click Format / Beautify, Minify, or Validate Only.
  3. If validation fails, read the parser message — it names the unexpected token or mismatched tag.
  4. Copy the result or download it as an .xml file.

Frequent XML Mistakes the Validator Catches

  • Mismatched tags<item>…</Item> fails because XML is case-sensitive.
  • Unclosed elements — every tag needs a closing tag or self-closing form <br />.
  • Unescaped special characters — a bare & or < in text must be written as &amp; / &lt;.
  • Multiple roots — a document may contain only one top-level element.
  • Attribute quoting — all attribute values must be quoted: id=5 is invalid.

Frequently Asked Questions

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

Well-formed means the syntax is correct (proper nesting, quoting, escaping) — that is what this tool checks. Validity additionally means the document obeys a specific schema (DTD/XSD), which requires the schema file and is a separate step.

Will formatting break my CDATA sections?

No. CDATA blocks are passed through untouched, character for character, as are comments and the XML declaration.

Why does minified XML sometimes behave differently?

In rare document types, whitespace between elements is significant (mixed-content documents like XHTML). For data-oriented XML (configs, feeds, SOAP) minification is completely safe.

Can it format huge files?

Documents of several megabytes format fine in modern browsers. Everything is processed locally, so nothing is uploaded regardless of size.