b2KIT

XML Formatter & Validator

Format, validate, and minify XML documents with syntax highlighting and schema validation.

Tested tool guide Tested browser tools Checked August 16, 2026

What XML Formatter & Validator does, with a checked example

Paste XML into this tool to check whether it is well-formed, then reformat it with consistent indentation or strip that indentation back out into a compact single line. It parses the document the way any XML parser must: matching every start tag to its end tag in strict nesting order, confirming a single root element, and requiring quoted attribute values. The mistake people hit most often isn't a misspelled tag - it's an unescaped ampersand or a bare angle bracket inside plain text, which XML always reads as the start of markup rather than literal data.

Worked example

A concrete input and expected output from the current implementation.

Input

<root><child>Hello</root></child>

Expected output

Not well-formed: mismatched closing tag. <child> was opened after <root>, so it must be closed before </root> appears - the parser expected </child> and found </root> instead.

XML requires elements to nest strictly: whichever tag opened last must close first. Here <root> closes while <child> is still open, which violates that rule regardless of how the tags are spelled.

How the result is produced

1

Well-formedness and schema checks

Every document is parsed against the core XML grammar: tags must be properly nested and closed, there must be exactly one root element, attribute values must be quoted, and characters like & and < may only appear as entities inside text. If the document declares a DOCTYPE or schema reference the tool can resolve, it is checked against that schema too; otherwise only well-formedness is verified, not conformance to any particular structure.

2

Reformat and minify

Formatting walks the parsed element tree and rewrites it with consistent line breaks and indentation per nesting level, without touching element names, attribute values, text content, comments, or their order. Minify does the reverse: it strips insignificant whitespace between tags to shrink the document. Both require the input to already be well-formed - a parse error stops formatting rather than producing partial output.

Good uses

  • Tracking down why a config file such as an Android manifest, a Maven pom.xml, or an RSS feed fails to parse, by locating the exact tag that breaks nesting
  • Pretty-printing a minified XML API response copied from browser dev tools so it's readable during code review
  • Minifying a hand-formatted XML document before embedding it in a config value or sending it over a size-constrained channel

Limits and checks

  • The validator typically stops at the first well-formedness error it hits; fixing that one and re-running may surface additional errors further into the document
  • Schema validation only runs if a DTD or XSD is declared in the document (or supplied separately) and is actually resolvable - a schema referenced by an unreachable path or URL means only well-formedness gets checked
  • Pretty-printing inserts and removes whitespace between tags; in documents that rely on significant whitespace, such as elements marked xml:space="preserve" or mixed content where spacing carries meaning, reformatting can change what the document means even though it stays well-formed

Common questions

Does this validate against my XSD or DTD, or just check that the XML is well-formed?

It always checks well-formedness - correct tag nesting, one root element, escaped special characters. Schema validation against an XSD or DTD only happens when the document declares one that the tool can resolve; without that, it confirms the XML is well-formed but not that it matches any particular schema.

Will formatting or minifying change my actual data?

No - both operations only change whitespace between tags: indentation and line breaks for formatting, removal of that whitespace for minifying. Element names, attributes, text, and comments are left alone. If the input isn't well-formed to begin with, formatting won't fix it; you'll need to correct the underlying error first.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools