Toolslay

XML Formatter & Validator

Paste cramped or broken XML below and this xml formatter indents it properly while flagging exactly where the structure breaks.

Loading tool…

About

About XML Formatter & Validator

An xml formatter restructures a dense, single-line XML string into a readable tree that shows how every parent and child element actually relates. This xml formatter validator checks something a plain formatter won't: whether the document is well-formed at all, meaning every tag is properly closed, properly nested, and the whole thing sits inside exactly one root element.

Free, no sign-up

Being well-formed is a lower bar than being valid, and the two get confused often. Well-formed just means the XML follows the basic syntax rules, matching tags, one root element, correctly escaped special characters. Valid means it also matches a specific schema, like a DTD or XSD, that defines which elements and attributes are actually allowed. This tool checks for well-formedness, which catches the vast majority of real-world XML errors.

XML requires five characters to be escaped wherever they appear as literal text rather than markup: & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot;, and ' becomes &apos;. An unescaped ampersand sitting in plain text, something that's easy to type by accident, is one of the single most common reasons an otherwise fine-looking XML file fails validation.

Paste your raw XML and get a properly indented tree back immediately, with tabs or spaces available depending on your team's conventions. If something's broken, the validator points to the exact line rather than leaving you to scan the whole document by eye.

This is especially useful for checking a generated sitemap or a configuration file before it goes live, since a single invalid character can get a sitemap rejected outright by a search engine's crawler. Everything runs locally, so a proprietary configuration file or a database export never leaves your browser.

FAQ

Frequently asked questions

What does it actually mean for XML to be formatted?

Formatting adds line breaks and indentation so a human can follow the document's structure. It doesn't touch the actual elements, attributes, or text content, only how the file is visually laid out.

Why does my XML fail validation even though it looks fine?

The most common causes are a missing closing tag, mismatched nesting, an unescaped ampersand in the text content, or having more than one root element wrapping the document. XML's rules are considerably stricter than HTML's on all of these points.

Can I use this to check a sitemap before submitting it to search engines?

Yes, sitemaps are XML documents, so this is a direct way to confirm a hand-edited or script-generated sitemap has no structural errors before a crawler ever sees it.

What's the real difference between well-formed and valid XML?

Well-formed means the document follows XML's basic syntax rules. Valid means it also conforms to a specific schema, like a DTD or XSD, that defines exactly which elements, attributes, and structures are allowed for that particular document type.

Is it safe to paste a confidential configuration file into this tool?

Yes, both formatting and validation run locally using your browser's own processing. Nothing you paste gets uploaded or logged on an external server.

Why do I need to escape characters like & and < in my XML content?

Because those characters have special meaning in XML markup itself, an unescaped & looks like the start of an entity reference, and an unescaped < looks like the start of a new tag. Escaping them tells the parser to treat them as literal text instead.