Eazy Toolbox
Skip to tool

XML Formatter

Re-indent XML so its structure is readable, and find out immediately if it is not well-formed. CDATA sections and declarations are preserved exactly.

Your data never leaves your browser. This tool runs entirely on your device.

Formatted
Paste some XML to format.

Well-formed versus valid

These are two different checks and the distinction matters. Well-formed means the syntax is correct: every element is closed, tags nest properly, attribute values are quoted, and there is exactly one root element.

Valid means the document also conforms to a schema — a DTD, XSD or RelaxNG — that defines which elements may appear where. This tool checks well-formedness, which is the prerequisite for everything else.

How XML differs from HTML

XML is far stricter. Every element must be explicitly closed, tag names are case-sensitive, and attribute values must always be quoted. HTML forgives all three.

That strictness is why an XML formatter can safely reject input, while an HTML formatter has to accept whatever it is given.

CDATA and declarations

A CDATA section marks text that must not be parsed as markup, which is how XML carries embedded code or content containing angle brackets. It is copied through byte for byte.

The XML declaration and any processing instructions are kept on their own lines at the top of the document.

Frequently asked questions

What does "not well-formed" mean?

The document breaks a basic syntax rule of XML — usually an unclosed tag, tags that overlap instead of nesting, an unquoted attribute value, or more than one root element. Any XML parser will reject it.

Does this validate against a schema?

No. It checks well-formedness only. Validating against an XSD or DTD requires the schema itself and a validating parser, which is a separate step.

Why can an XML file have only one root element?

Because the specification defines a document as a single element tree. Two sibling elements at the top level have no common parent, so there is no tree — wrap them in a container element.

Is HTML valid XML?

Usually not. HTML permits unclosed tags like <br> and <li>, and unquoted attributes, all of which XML forbids. XHTML was the strict variant designed to be both; use the HTML formatter for ordinary HTML.