well-formedness · not schema validation

XML formatter

Indent a document without losing what a token dumper would drop, and get the exact line when it is not well formed.

0 characters

Formatting happens in this tab. Configuration and SOAP payloads often carry internal hostnames, so nothing is uploaded.

Short answer: paste the document. If it is well formed you get the indented version and a count of elements, attributes, comments and depth; if not, you get the line the parser stopped on.

Well formed is not valid

These are two different checks and only the first one is possible without a schema. Well-formed means the document follows XML's syntax rules — one root, balanced tags, quoted attributes, escaped entities. Valid means it also matches a DTD or XSD. A document can be perfectly well formed and still be rejected by the service that expects a particular shape.

Why the formatter is order-preserving

A naive formatter rebuilds the document from a map of tag → value, which loses comments, reorders attributes and turns repeated child elements into an array that may not round-trip. Here the parse keeps the node order, so <!-- note --> stays where it was and a namespace prefix like soap: is not renamed.

Sending the result somewhere else? The JSON formatter and theYAML converter do the same job for other formats.

XML questions

Does this validate my XML against a schema?

No, and it will not pretend to. It checks well-formedness — balanced tags, quoted attributes, one root element — which is the layer that catches typos. DTD and XSD validation need the schema document and are a different job.

Is anything lost when I format it?

Comments, CDATA sections, processing instructions, namespace prefixes and attribute order are all preserved, because the parser runs in order-preserving mode. A formatter that drops a comment is a data-loss bug, not a formatting choice.

Why was my document rejected?

The usual causes are an unclosed tag, an attribute value without quotes, two root elements, or a bare ampersand. The message names the line and column, and the reason the parser gave.

What happens to the DOCTYPE?

A DOCTYPE is kept verbatim and placed back at the top of the output, but its internal subset is not parsed — entity declarations inside it are not expanded, and the page says so rather than quietly resolving them wrong.

Related tools