XML validator and formatter
Paste XML or open a file and the validator checks it as you type. Every error comes with the line, the column and what to change, such as a missing closing tag, an unescaped & or an attribute without quotes. Add an XSD schema to check the structure too, then format, minify, convert to JSON or try an XPath query. Everything runs in your browser.
Free · No sign-up
How to use it
- Paste your XML, open an .xml file, or load one of the examples.
- Read the status under the box. Well-formed XML shows the root element and counts; an error shows the line, the column and what to fix.
- Optional: open Validate against an XSD schema, paste the schema and click Validate to check the structure and data types.
- Choose formatted, minified or JSON output and copy or download it. Use the XPath box to find specific elements.
Why use this tool
Errors explained
Each error shows the line and column, a snippet with a pointer and a plain explanation of the fix, not a cryptic parser message.
XSD schema validation
Checks required elements, order, attributes and data types against your XSD with libxml2, the engine behind xmllint.
Formatter and minifier
Indent with 2 or 4 spaces or tabs, or minify to one line. Comments and CDATA are kept.
XML to JSON
Converts attributes to @name keys and repeated elements to arrays, ready to use in JavaScript.
XPath tester
Run an XPath expression and see the matching nodes, a count or a value.
Private
Your XML is never uploaded. Config files and API payloads with secrets stay in your browser.
Well-formed or valid: what is the difference?
Well-formed XML follows the basic syntax rules: one root element, every tag closed in the right order, attribute values in quotes and special characters escaped. Any XML parser rejects a document that is not well formed.
Valid XML is well formed and also matches a schema, usually an XSD, that says which elements and attributes are allowed, in which order and with which data types. A sitemap, an invoice or a SOAP message can be well formed and still be rejected because it is not valid.
Common XML errors and how to fix them
| Error | Cause | Fix |
|---|---|---|
| Mismatched tag | </Item> closes <item>; XML is case-sensitive | Use exactly the same name and close tags in reverse order |
| Unescaped ampersand | Text such as Tom & Jerry | Write & |
| Attribute without quotes | qty=2 | Write qty="2" |
| More than one root | Two top-level elements | Wrap them in one parent element |
| Content before the declaration | A space or BOM before <?xml | Start the file with <?xml |
| HTML entity | or © | Use   or © |
Characters you must escape in XML
| Character | In text | In attribute values |
|---|---|---|
| & | & | & |
| < | < | < |
| > | > (recommended) | Allowed |
| " | Allowed | " inside double quotes |
| ' | Allowed | ' inside single quotes |
Privacy
The validator runs in your browser. Well-formedness is checked by our own parser and the browser, XSD validation by libxml2 compiled to WebAssembly. Your XML and schema are never sent to a server. Your last input is kept in this browser only.
Frequently asked questions
How do I check if my XML is valid?
Paste it into the box above. The status line shows at once whether it is well formed and, if not, the line and column of the first error. To check it against a schema, open Validate against an XSD schema.
Can I validate XML against an XSD online?
Yes. Paste or open your XSD below the editor and click Validate against schema. You get every schema error with its line number.
Why does my XML say the tags do not match?
XML is case-sensitive and tags must close in reverse order. <Item> and </item> are different tags, and <a><b></a></b> is not allowed.
Why is & not allowed in XML?
The ampersand starts an entity such as <. On its own it must be written as &, also inside URLs in attribute values.
Does it support namespaces and DTDs?
Namespaces are checked: every prefix must be declared. A DOCTYPE is accepted, but external DTDs are not loaded, so DTD validation is not done. Use XSD for validation.
How do I convert XML to JSON?
Paste well-formed XML and choose JSON above the result. Attributes become keys starting with @, repeated elements become arrays, and text inside elements with attributes becomes #text.
XML syntax rules with examples
Related tools
Need something built?
Tell us what you want to create.
Tell us what you need built, from a simple website to a complete app, AI solution, automation, or custom system.