XML formatter
Processed in your browser · nothing is uploaded
Re-indents an XML document by nesting depth, minifies it, or checks it is well-formed using the browser’s own parser.
How to use the xml formatter
Well-formed and valid are different things and the difference matters. Well-formed means the syntax holds: every tag closed, correctly nested, one root element, attributes quoted. Valid means it additionally conforms to a DTD or schema saying which elements may appear where. This checks the first and not the second, because the second needs the schema.
Two strictnesses catch people coming from HTML. Tags are case-sensitive, so <Book> does not close <book>. And a bare ampersand is illegal anywhere at all: it starts an entity reference, so a URL with ?a=1&b=2 in it has to be written &b=2 even inside an attribute value. The error the parser gives for that one rarely mentions the ampersand.
The formatter indents by depth without parsing, which sets its limits. It will not tell you a tag is unbalanced; an unclosed element shows up as everything below it drifting one level to the right, which is usually enough to find it. And a CDATA section holding markup is split like any other tag, so a document that embeds HTML that way is better left unformatted.
Minifying is lossier than it looks. Runs of whitespace are collapsed everywhere, text content included, and xml:space="preserve" is not honoured, so an element holding a code sample, a formatted address or anything else where the spacing is the content should not go through it.
Questions
Well-formed is correct syntax. Valid additionally conforms to a DTD or schema. This checks well-formedness.
A bare & starts an entity reference. It must be written & everywhere, attributes included.
Yes, unlike HTML. <Book> does not close <book>.
No. Exactly one, or it is not well-formed.
Format will not: it indents what it is given, so the problem appears as everything below drifting right. Check well-formed for the actual message.
Not always. Whitespace runs are collapsed inside elements too, and xml:space="preserve" is ignored. Leave documents with significant spacing alone.
No. It is parsed by your own browser.