XML Formatter / Validator
Format XML and find out whether it is actually well-formed.
What you paste
Parsed in your browser — never uploadedHow this reads your output
The document is parsed before it is formatted, which is the important ordering: a mismatched or unclosed tag produces an error naming the problem rather than being silently reformatted into tidier nonsense. Once it parses, elements are indented by depth, with short text content kept on the line of its opening tag so a single-value element reads as one line rather than three.
What the results mean
- Well-formed
- Every element closes, in the right order, under exactly one root. This is the syntactic requirement all XML must meet.
- Self-closing
- Elements written with a trailing slash and no content. Equivalent to an empty pair of tags, and purely a style choice.
- Declaration
- The optional processing instruction at the top. Its main job is declaring the encoding when it is not UTF-8.
Common problems and fixes
- A parser rejects a document that looks fine
- Look for a bare ampersand first, since it must be written as & even inside text, and it is the most common cause. After that, check for a stray angle bracket in content, an attribute value without quotes, and a byte order mark before the declaration, which some parsers reject outright.
- Special characters appear as question marks
- The encoding declared in the XML declaration does not match how the file was actually saved. Declare UTF-8 and save as UTF-8. Note that if the two disagree, the declaration is what the parser believes, so an incorrectly declared file fails in ways that look like data corruption.
Frequently asked questions
What is the difference between well-formed and valid?
Well-formed means the syntax is correct: tags nest properly, everything closes, one root element. Valid means it also conforms to a schema defining which elements may appear where. A document can be perfectly well-formed and completely wrong for its purpose.
Does formatting change the meaning?
It can, in one narrow case. Whitespace between elements is not always insignificant in XML, and a consumer relying on mixed content spacing could see a difference. It is rare, and worth knowing before reformatting a document you did not write.
Why is XML still used?
Because it does things JSON does not: schemas with real validation, namespaces that let vocabularies mix without collision, transformation with XSLT, and digital signatures over document subsets. Configuration and web APIs moved to JSON and YAML, while document formats, publishing and enterprise messaging did not.
Put this on your own site
Free to embed, no attribution required beyond the source link the frame carries itself. It runs entirely in your visitor's browser, sets no cookies and loads no third-party script.
<iframe src="https://runthetests.com/embed/xml-formatter/" width="100%" height="720" style="border:1px solid #e5e5e5;border-radius:8px" title="XML Formatter / Validator" loading="lazy"></iframe>
Preview it at https://runthetests.com/embed/xml-formatter/. Embedded pages are marked noindex, so yours stays the canonical copy — not this one.