A SOAP envelope, an RSS feed, a config file, or one long line from a log.
2
Choose format or minify
Indent with two or four spaces, or remove the whitespace entirely.
3
Copy the result
A mismatched tag is reported by the parser, with its message, instead of being passed through.
Well-formed is not valid
An XML document is well-formed when its tags balance, its attributes are quoted and it has one root element. That is what the browser's parser checks here, and a failure is reported with the parser's own message. Well-formed does not mean valid: validity means the document matches a schema or DTD, and this page does not have one to check against.
So a document can format cleanly and still be rejected by the service you send it to, because a required element is missing or in the wrong order. Formatting is a readability tool, not a conformance test.
Whitespace and mixed content
Indenting adds whitespace inside elements. In a document where elements contain only elements, that is harmless. In mixed content — text and elements interleaved, as in an XHTML paragraph with a bold word — the added whitespace becomes part of the text, and a consumer that compares text nodes may notice.
This formatter drops whitespace-only text nodes and indents the structure, which is right for data documents and wrong for a handful of prose-like ones. If the whitespace is significant, use minify instead, which removes indentation rather than adding it, or edit by hand.
What is preserved
The XML declaration, comments and CDATA sections are kept. Attributes are written in their original order and values are not re-escaped. Entities are left as written where the parser exposes them as text; the parser resolves the five built-in entities, so an & may come back as & after re-escaping, which is correct but can look like a change.
External entities and DTDs are not fetched, which is a deliberate protection against XXE-style attacks. A document that relies on an external DTD for its entity definitions will therefore fail or lose those entities. To convert the result to JSON, use the XML and JSON converter.
Frequently asked questions
Does it validate against a schema?No. It checks that the XML is well-formed, not that it matches an XSD or DTD.Can formatting break mixed content?Yes. Indentation adds whitespace inside elements, which matters when text and elements are interleaved.Are comments and CDATA preserved?Yes, both are kept.What about DOCTYPE and external entities?They are not fetched, deliberately. Documents depending on an external DTD may lose entities.Is my XML uploaded?No. The browser's XML parser and the formatter run in this tab.Can it minify instead?Yes. Minify removes indentation and puts the document on one line; preformatted content is not otherwise changed.