XML Formatter and Validator Online

Pretty print an XML file, check that it is well-formed, or minify it to save space. Errors are reported with their line number.

Your XMLCtrl + Enter
Result

What does an XML formatter do?

XML returned by APIs or exported by software (invoices, RSS feeds, Maven or Android configuration files…) is often squeezed onto a single line. The formatter re-indents it so the tag hierarchy becomes visible: every child element is shifted under its parent.

Validate XML: is it well-formed?

An XML document is well-formed when it follows the basic syntax rules:

  • exactly one root element;
  • every opening tag has a closing tag (or is self-closing, like <br/>);
  • tags are properly nested;
  • attribute values are quoted;
  • < and & are escaped in text.

The Validate button checks these rules and shows the line and column of the first error. This is not schema validation (XSD or DTD): a file can be well-formed and still not match the schema an application expects.

Minify XML

Minifying removes whitespace and line breaks between tags, making the file lighter and faster to transfer. You can keep or remove comments. CDATA sections and element text are preserved.

Privacy

Everything is processed locally in your browser. Your XML files are never uploaded or stored.

FAQ

Does the formatter change my XML content?

No. Only whitespace between tags changes. Tag names, attributes, namespaces, comments and CDATA sections are kept.

Why is my XML reported as invalid?

The most common causes are an unclosed tag, an unescaped ampersand (&), missing quotes around an attribute, or more than one root element. The error message points to the line involved.

Can I format HTML with this tool?

Only if it is well-formed XHTML. Regular HTML allows unclosed tags that XML rejects.

Is there a size limit?

There is no fixed limit: it depends on your device's memory. Files of several megabytes are usually processed in under a second.

More free tools