Skip to main content
Convert2JSON
Developer ToolsBrowser processing

XML Validator

Check whether an XML document is well-formed, and get the exact position of the first thing that breaks it.

Input

XML
characters
0
lines
0
size
0 B
Your data stays on your device.Parsing, conversion and code generation happen in this browser. Input is not uploaded to Convert2JSON servers.Privacy policy

About this tool

Almost every XML failure in practice is one of four things: a tag that is never closed, tags closed in the wrong order, an attribute value without quotes, or a bare ampersand that should have been an entity. All four produce parser messages that name a symbol rather than a cause, which is why the report rewrites them into a sentence about the document.

When the document does parse, the report describes what it found — the root element, how many elements and attributes there are, and how deeply they nest. That is usually enough to confirm you have the file you expected before spending time on it.

This is well-formedness, not schema validation. A document can be perfectly well-formed and still be wrong for its purpose, and the report says so rather than letting the word valid be read as a broader promise than it is.

How to use this tool

  1. Paste XML, upload a file, or drop one onto the editor.

  2. Press Validate.

  3. If it fails, use the reported line and column to go to the problem.

  4. If it passes, read the summary to confirm the root element and size are what you expected.

Key features

  • Well-formedness checking with the line and column of the first error
  • Parser messages rewritten into plain descriptions of the cause
  • An excerpt of the offending line shown alongside the error
  • Element, attribute and nesting-depth counts when the document passes
  • The encoding declared in the prolog reported when present
  • Runs entirely in the browser, so the document is never uploaded

Example

An unclosed element

InputXML

<inventory>
  <item sku="TENT-2P">
    <quantity>34
  </item>
</inventory>

OutputReport

The XML has a tag that is never closed or is closed
out of order. Expected closing tag 'quantity'
(opened in line 3, col 5) instead of 'item'.

Line 4, column 3

Good to know

  • Only the first error is reported. XML parsing cannot reliably continue past a structural failure, so fix it and validate again.
  • DTD and XSD validation are not performed — this checks syntax, not whether the document matches a schema.
  • The declared encoding is reported but not enforced; the file is read as the browser decoded it.

Frequently asked questions

What does well-formed actually mean?

That the markup obeys the rules of XML itself: one root element, every tag closed and correctly nested, attribute values quoted, and reserved characters escaped. It says nothing about whether the elements are the ones a schema expects.

Can it validate against my XSD or DTD?

No. This tool checks syntax only. If you need to check a document against a schema, that is a different job and this page will not pretend to do it.

Why does an ampersand break my document?

A bare ampersand starts an entity reference, so the parser expects a name and a semicolon to follow. A literal ampersand in text or in an attribute value has to be written as an escaped entity.

Why is only one error shown?

After a structural error the parser can no longer tell where elements begin and end, so any further errors it reported would be guesses. Fixing the first one usually resolves several apparent problems at once.

Your data stays on your device

Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.