Validate well-formedness and pretty-print XML
A tool that checks whether your XML is well-formed using the browser's own native XML parser, then re-indents valid XML for readability — not a regex guess, a real parse.
Paste your XML.
Pick an indentation style.
Click Validate & Format, then copy the result.
Well-formed means the syntax itself is correct — every tag properly closed and nested, attributes quoted, one root element. Valid goes further, checking conformance against a specific schema (XSD or DTD) that defines exactly which elements and attributes are allowed. This tool checks well-formedness only.
When the XML isn't well-formed, the status badge shows the browser parser's own error message — the same kind of message you'd get from any standards-compliant XML parser, describing exactly what broke and roughly where.
Choose 2 spaces, 4 spaces, or a tab character for the re-formatted output. Switching the option after formatting re-runs it automatically.
Comments, <![CDATA[...]]> sections, processing instructions like the
<?xml version="1.0"?> declaration, and DOCTYPE declarations are all kept
exactly as written, not reformatted or altered internally.
No. Schema validation checks that your XML follows a specific set of rules about allowed elements, attributes, and structure — a separate, more specific check than well-formedness. This tool doesn't accept or check against an XSD or DTD file.
No. It only checks well-formedness — correct XML syntax, like matched tags and proper nesting — not validity against a specific schema. A file can be perfectly well-formed and still violate a schema's rules about what elements or attributes are allowed.
Well-formed means the XML syntax itself is correct: every tag is properly closed and nested, attributes are quoted, and so on. Valid means it also conforms to a specific schema (XSD or DTD) that defines which elements, attributes, and structures are allowed. This tool checks the former, not the latter.
For XML with mixed content — text and child elements together in the same parent, like a sentence with a bolded word in the middle — yes, potentially. The formatter adds whitespace and line breaks around child elements, which becomes part of the surrounding text nodes. If your XML consumer reads text content literally without trimming, that extra whitespace changes what it sees. Purely structural XML (elements containing only other elements, no mixed text) isn't affected.
Comments, CDATA sections, processing instructions (like the XML declaration), and DOCTYPE declarations are all kept exactly as written, not reformatted or re-indented internally.
Real validation. It uses the browser's own native XML parser (DOMParser) to actually parse the document, so a genuine syntax error is reported, not guessed at with a regex.
No. Validation and formatting both happen entirely in your browser. Nothing you paste here is uploaded anywhere.