Formatters & Code
XML Formatter
Format and check XML in the browser.
Results appear here.
What the result means
The formatter asks the browser to parse the text as XML. If the document is not well formed, the parser supplies an error element and this page shows that text instead of a half-built tree. A successful document is walked node by node and reprinted with a two-space indent. Each element keeps its node name, so a prefix that was in the source stays on the tag, and namespace declarations stay in the attribute list. Text that is more than whitespace is kept, with whitespace runs collapsed. Comments are kept. The browser parser does not load external entities, and this page does not ask it to. The reprint is easier to read than the input, not a byte-for-byte copy, and it is not schema validation.
Related tools
Questions
Why did it fail?
The browser rejected the text before a formatted tree was built. The message on the page is the parser error text, which usually points at a mismatched tag, an unescaped ampersand, or a character the grammar does not allow. XML needs one root element and quoted attributes. Fix the first problem it names, because later complaints often follow from that one.
Does this support namespaces?
Prefixes are kept because each element is written with its node name, which still includes a prefix when the source had one. xmlns attributes stay in the attribute list and are not rewritten. The page does not rename prefixes, resolve a schema, or drop a declaration it does not recognise.
Are comments and text kept?
Comments are kept. Text that contains more than whitespace is kept, with runs of whitespace collapsed to a single space. Line breaks that only indented the original file are replaced by a two-space indent. If you need the original bytes unchanged, keep a copy before you format.