b2KIT

XML Formatter & Validator

Format, validate, and beautify XML with syntax highlighting, indentation control, and error detection.

Tested tool guide Tested browser tools Checked August 16, 2026

What XML Formatter & Validator does, with a checked example

Paste XML into the input pane and the tool reparses it, then reprints it with consistent indentation, line breaks between elements, and syntax highlighting for tags, attributes, and text nodes. Any well-formedness problem - a missing closing tag, an unescaped ampersand, two root elements - is flagged with the line and column where the parser gave up, rather than being silently swallowed. What trips people up: it checks well-formedness, not validity against a DTD or XSD, so a document can pass here and still be rejected by a schema-aware consumer downstream.

Worked example

A concrete input and expected output from the current implementation.

Input

<root><item id="1">First</item><item id="2">Second</item></root>

Expected output

<root>
  <item id="1">First</item>
  <item id="2">Second</item>
</root>

The parser accepts the input as well-formed (one root, all tags closed) and reprints each element on its own line with a 2-space indent per nesting level; attribute order and text content are left unchanged.

How the result is produced

1

Formatting pass

The parser builds a tree from your markup, then serializes it back out with a fixed indent step and one node per line. Self-closing tags stay self-closed, attribute order is preserved, and text content is left untouched aside from trimming surrounding whitespace, so running formatted output back through the tool produces the same result again.

2

Well-formedness checking

Before formatting, the input must satisfy plain XML syntax rules: exactly one root element, every start tag matched by a closing tag, attribute values quoted, and reserved characters like & and < escaped in text. Any violation stops formatting and surfaces an error pointing at the offending line instead of returning a formatted-but-wrong result.

Good uses

  • cleaning up a minified XML API response or config file so it's readable before editing
  • checking whether a hand-edited XML file, such as an RSS feed or SOAP payload, is well-formed before sending it
  • converting inconsistently indented XML pulled from multiple sources into one consistent style before a diff or code review

Limits and checks

  • Only checks well-formedness, not validity - a document with element or attribute names that violate a schema can still format cleanly if it's syntactically sound XML.
  • Formatting normalizes whitespace between tags; if a document relies on significant whitespace in mixed content, the reformatted version may render differently even though it remains valid XML.
  • Namespace prefixes are preserved as plain text but their URIs aren't resolved or checked, so a typo'd or undeclared prefix passes formatting without any warning.

Common questions

Will this catch a typo in an element name defined by my schema?

No. The tool only confirms the XML is well-formed - correctly nested and escaped. It has no concept of your schema's allowed element or attribute names, so a misspelled tag that's still properly closed will format without any error.

Does my XML file get uploaded anywhere?

No. Parsing and formatting happen in your browser; the content isn't sent to a server, which also means very large files are limited by your device's memory rather than an upload cap.

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