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

Paste XML, open a file or load an example. It is checked as you type.

Result
Result type

    
Indentation
Validate against an XSD schema

Paste or open the XSD file. The XML is checked against it with libxml2, the same library behind xmllint. It is loaded only when you use it (about 800 KB).

Test an XPath expression

Examples: //item/title, count(//url), //feature[@enabled='true']/@name. For elements in a default namespace use //*[local-name()='loc'].

XSD validation by libxml2 / xmllint-wasm (MIT).

How to use it

  1. Paste your XML, open an .xml file, or load one of the examples.
  2. 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.
  3. Optional: open Validate against an XSD schema, paste the schema and click Validate to check the structure and data types.
  4. 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

ErrorCauseFix
Mismatched tag</Item> closes <item>; XML is case-sensitiveUse exactly the same name and close tags in reverse order
Unescaped ampersandText such as Tom & JerryWrite &amp;
Attribute without quotesqty=2Write qty="2"
More than one rootTwo top-level elementsWrap them in one parent element
Content before the declarationA space or BOM before <?xmlStart the file with <?xml
HTML entity&nbsp; or &copy;Use &#160; or &#169;

Characters you must escape in XML

CharacterIn textIn attribute values
&&amp;&amp;
<&lt;&lt;
>&gt; (recommended)Allowed
"Allowed&quot; inside double quotes
'Allowed&apos; 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 &lt;. On its own it must be written as &amp;, 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.

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.

Tell us what you want to build. We review every enquiry and reply by email.

Contact

Thanks, your enquiry is on its way.

We will review the details and reply by email.