XML Nerd
A cartoon tree frog in round glasses, thinking

XML Formatter and Validator

Format, validate and minify XML in your browser.

Runs in your browser. Nothing you type is uploaded.

How the XML formatter works

Paste XML into the box and press Format to indent it neatly with 2 spaces, 4 spaces or tabs. Minify removes the whitespace between tags, and Validate checks that the document is well-formed without changing it. Tick Remove comments to drop comments from the result.

What stays the same

Formatting only changes the whitespace between tags. Text, attribute values, entities, CDATA sections and processing instructions are kept exactly as written. Elements that mix text and tags, such as <p>Hello <b>world</b></p>, are left on one line so no meaningful space is added, and content marked xml:space="preserve" is never touched.

FAQ

How do I find a syntax error?

If the XML is not well-formed, you get a message such as "Mismatched end tag: expected <b> but found <a>" with the line and column, and that position is selected in the input box.

What are the most common XML mistakes?

A tag that is never closed, tags closed in the wrong order, attribute values without quotes, a bare & that should be &amp;, and more than one root element.

Does it validate against a schema or DTD?

No. It checks that the XML is well-formed, meaning the syntax is correct. It does not check the document against an XSD schema or DTD, and it does not parse the contents of a DOCTYPE or check that namespace prefixes are declared.

Is my XML uploaded anywhere?

No. Everything runs in your browser, so configuration files and API responses stay on your device.

More XML tools

  • XML validator: Check that XML is well-formed and find the exact line and column of an error.
  • XML beautifier: Pretty print XML with 2 spaces, 4 spaces or tabs.
  • XML minifier: Strip the whitespace between tags to make XML as small as possible.
  • XML sitemap generator: Turn a list of URLs into a sitemap.xml file for search engines.