Paste XML and get it properly indented, or minified, with well-formedness checked as you type. When something is wrong you get the line and column and a specific reason — a close tag that matches nothing, tags that overlap instead of nesting, an element never closed — rather than the localised paragraph a browser's own parser produces, which differs between browsers and often carries no usable position at all. Three details are handled that trip up regular-expression formatters: a greater-than sign inside a quoted attribute does not end the tag, markup inside a comment is not markup, and CDATA is kept verbatim because holding text that would otherwise be parsed is its entire purpose. Whitespace inside xml:space="preserve", and inside pre, script, style and textarea, is left exactly as written — reflowing it would change what the document means. Drop a file or paste; nothing is uploaded.
| Written | Problem |
|---|---|
| <a><b></a> | <b> is never closed |
| <b><i></b></i> | Tags overlap rather than nest |
| </a> | Closes something never opened |
| <a href=x> | Attribute value must be quoted |
| <br> | Fine in HTML, needs <br/> in strict XML |
| a < b | A bare < must be written < |
No. It is parsed and formatted in your browser. XML files routinely carry configuration and credentials, so this is not incidental.
Because its error reporting is unusable for this. A failure comes back as a localised sentence inside a parsererror element, worded differently in each engine and frequently with no position. Scanning the document directly gives the same line and column everywhere.
Most often a tag that is never closed, a close tag that matches nothing, or tags that overlap rather than nest — writing <b><i></b></i> instead of <b><i></i></b>. Attribute values must also be quoted, which HTML forgives and XML does not.
No. CDATA is kept exactly as written, as is anything inside xml:space="preserve", pre, script, style or textarea. Reformatting those would change what the document says rather than just how it looks.
Partly. Void elements like <br> and <img> are understood so they are not reported as unclosed, but HTML has its own rules about optional closing tags. For HTML, use the dedicated HTML formatter.
No. It checks well-formedness — that the structure is valid XML — not validity against a DTD or XSD, which is a separate and much larger question requiring the schema itself.
Formatting is done by a purpose-written tokenizer rather than by DOMParser and XMLSerializer, for the same reason the JSON tools avoid the engine's parse messages: the browser reports a malformed document as a localised sentence inside a parsererror element, with wording that differs per engine and no dependable position, so a tool built on it points at the right place in one browser and gives an unhelpful paragraph in another. Here the document is scanned directly and the first structural problem is reported with a line and column — a close tag that matches nothing, a close tag that overlaps rather than nests, an unclosed element, or a tag missing its bracket — each named specifically rather than as a generic failure. Three things the tokenizer has to get right, all of which a naive regular expression gets wrong. A greater-than sign inside a quoted attribute value does not end the tag, so quoting is tracked while scanning. Markup inside a comment is not markup, so a less-than inside one must not open an element. And CDATA exists precisely to hold text that would otherwise be parsed, so it is captured whole and never interpreted. Indentation is then structural, with one concession that matters: whitespace inside an element carrying xml:space="preserve", or inside pre, script, style or textarea, is emitted exactly as written. Reflowing those silently changes what the document says, which is the difference between formatting and corruption. Short text between an open and close tag stays on the line rather than being split across three, because that is how a person would write it. Minifying collapses the whitespace that is only formatting while keeping whitespace that separates words, and leaves preserved regions untouched.