Skip to content
Codoryn Search tools

XML Formatter & Validator

Format XML and check it is well-formed, in your browser. External entities are refused, and the tool loads no DTD, schema or other resource from the network.

Well-formed is not the same as valid

This tool checks that your XML is well-formed: tags are balanced and nested correctly, attributes are quoted, and the syntax is legal XML 1.0.

It does not check your document against an XSD, a DTD, or any other schema. That is a different question — "does this document match the shape someone defined?" — and answering it would mean accepting or fetching a schema. Codoryn does neither, and does not claim otherwise.

Why a DOCTYPE is refused

Codoryn rejects every document containing a <!DOCTYPE> declaration, whether it points somewhere external, declares entities internally, or declares nothing at all.

This is deliberately blunter than filtering. Custom entities can only be declared in a DTD, so refusing all DTDs removes the entire class of external-entity (XXE) and entity-expansion ("billion laughs") attacks by construction rather than by a filter that has to be correct. It also removes the internal-versus-external distinction, which is precisely where such filters have historically been bypassed — an internally declared parameter entity can pull in an external subset.

The cost is real and worth stating: a harmless DOCTYPE line is refused too. Remove it and the document will be processed. The five predefined entities and numeric character references need no DTD and work normally.

What formatting preserves

  • Mixed content is never re-indented. An element holding both text and child elements is emitted inline, because adding whitespace there changes the document's meaning. This is the single most important rule here.
  • xml:space="preserve" subtrees are emitted verbatim.
  • CDATA stays CDATA and is never converted to escaped text or re-indented.
  • Namespaces, prefixes and declarations are kept exactly, never rewritten or minimised.
  • Attribute order is preserved as written and never sorted.
  • Comments and processing instructions are preserved. No URI in them is ever followed — including xml-stylesheet.

Frequently asked questions

Do you validate against my XSD?

No, and it never fetches one. Schema validation is out of scope for this version.

Why was my DOCTYPE rejected?

See above — it is a security decision, not a parsing failure. Removing the line will let the document through.

Why is some of my content on one line?

Because it is mixed content, and indenting it would change what the document says.

Is my XML uploaded?

No. Parsing and formatting happen in a Web Worker on your device, and no request of any kind is made.

Send output to