XML Formatter and Validator
Indent, minify and check XML, RSS, SVG, SOAP and configuration files, with colour highlighting and errors that name the line and the column. A mismatched tag tells you which opening tag it failed to match, and where that one is.
Size
Elements
Attributes
Depth
How to use it
- Paste your XML on the left. It is checked as you type.
- Choose Format to indent it, or Minify to strip the whitespace between elements.
- If it will not parse, read the message. It gives the line, the column, a caret under the exact character, and what was actually wrong.
- Copy or download the result.
Mixed content is left exactly as you wrote it
This is where most XML formatters quietly damage documents. Consider:
<p>Hello <b>bold</b> world</p>A formatter that indents everything turns that into three lines, and in doing so invents whitespace either side of <b> that was not there before. In XML the space between text and an inline element is content, not layout. Once a stylesheet or a reader renders it you get Hello bold world with the spacing changed, or doubled, or lost.
So when an element holds both text and child elements, this page reproduces it byte for byte and indents around it instead. Elements that hold only other elements are indented normally, and an element holding only text stays on one line. That is the behaviour you want and rarely get.
Errors name both ends of the problem
The one thing you need to know about a mismatched tag is which opening tag it was meant to close. So instead of "mismatched tag at line 40", you get:
<item> was opened on line 12 but </channel> closes it here.
Tags have to be closed in the order they were opened.And when the names differ only in case — the mistake anyone arriving from HTML makes — it says so directly rather than leaving you comparing two identical-looking words.
What stops XML parsing
| Problem | Looks like | Why |
|---|---|---|
| Mismatched tag | <a><b></a> | Tags close in the order they opened. |
| Wrong case | <Note>x</note> | XML names are case-sensitive. HTML lets this go; XML does not. |
| Unquoted attribute | <a id=1/> | Every attribute value needs quotes, even a number. |
| Bare attribute | <a checked/> | XML has no valueless attributes. Write checked="checked". |
| Duplicate attribute | <a id="1" id="2"/> | A name may appear once per tag. |
| Bare ampersand | <a>Tom & Jerry</a> | Write &. This is the single most common XML error. |
| Two roots | <a/><b/> | A document has exactly one root element. |
| -- inside a comment | <!-- a -- b --> | Genuinely illegal, and it surprises everyone. |
The five entities
XML defines exactly five named entities. Everything else has to be a numeric reference such as ©, or be declared in a DOCTYPE.
& | & | Ampersand. Must always be escaped. |
< | < | Less than. Must always be escaped in text. |
> | > | Greater than. Escaping is optional but usual. |
" | " | Double quote. Needed inside a double-quoted attribute. |
' | ' | Apostrophe. Needed inside a single-quoted attribute. |
If you need a genuine < or & in a block of text — an embedded script, or some HTML inside a feed — wrap it in <![CDATA[ ... ]]> and none of it needs escaping.
Questions
Is my XML uploaded anywhere?
No. It is parsed in your browser. Worth knowing, because XML usually turns up as a SOAP request, an export or a configuration file, and those carry credentials and customer data far more often than people think.
Will it format HTML?
Only HTML that happens to be well-formed XML. HTML allows unclosed tags like <br> and <li>, bare attributes and mismatched case, none of which are legal XML. XHTML and SVG are fine.
Does it validate against a schema?
No. It checks that the document is well-formed — tags matched and nested properly, attributes quoted, entities complete. Checking it against a DTD, XSD or RELAX NG is a different job and needs the schema itself.
Why did trimming change my document?
Because whitespace inside an element is technically content. Trimming the padding around text is what a formatter is expected to do and what you almost always want, but it is a change, so it can be turned off. Mixed content is never trimmed either way.
How large a document can it handle?
Several megabytes. Past about 200,000 characters the result stops being colour highlighted — one span per token is what makes a browser struggle, not the parsing — and Copy and Download still give you everything.
Why does it refuse very deeply nested documents?
Anything past 500 levels is rejected with a message rather than parsed, because beyond that a recursive parser runs out of stack and takes the tab with it. Real documents are rarely deeper than ten.
Does it work offline?
Once the page has loaded, yes.