Developer Tools

XML Formatter & Validator

Format XML with proper indentation, or check whether it's well-formed, entirely in your browser.

XML Formatter and Validator Tool

Format or Validate XML

How to Use This Tool

  1. Paste your XML into the input box, or click "Load Sample" to try an example.
  2. Click "Format XML" for a readable, indented version, or "Validate XML" to check whether it's well-formed.
  3. Copy the result.

Example

Input:

<root><item>Hello</item><item>World</item></root>

Formatted:

<root>
  <item>Hello</item>
  <item>World</item>
</root>

"Well-Formed" vs. Schema-Valid

This tool checks whether your XML is well-formed -- correct basic syntax, like properly closed and nested tags. It does not check your document against an XSD or DTD schema (which would additionally verify things like "this element is only allowed to appear twice" or "this attribute must be a number"). A result of "Valid XML" here means well-formed, not schema-validated.

Frequently Asked Questions

What does "well-formed" mean, and is that the same as "valid"?

Well-formed means the XML follows the basic syntax rules -- every tag is properly closed, tags are properly nested, there's exactly one root element, and so on. This is different from schema validation (checking against an XSD or DTD, which defines which elements/attributes are allowed and in what structure) -- this tool only checks well-formedness, and will never claim "Schema Valid."

How is well-formedness actually checked?

Using your browser's own built-in XML parser (the same one used internally by browsers for XML documents), not a hand-written regex checker -- so unclosed tags, mismatched tags, and other structural problems are detected accurately and reported with a real parser error message.

What happens to comments and CDATA sections when formatting?

Both are preserved exactly -- comments stay as <!--...--> and CDATA sections stay as <![CDATA[...]]>, in their original position in the document.

Does formatting preserve attributes?

Yes -- every attribute and its value is kept on the formatted element exactly as written (values are re-escaped for safety, but never altered).

Why is an element like <item>Hello</item> kept on one line instead of broken across three?

An element whose only content is a single piece of text is kept inline for readability, matching how most hand-formatted XML looks -- only elements that contain other elements (or multiple pieces of content) get broken across lines.

Is my data sent anywhere?

No. Every check and transformation runs locally in your browser. Nothing you paste here is sent to Brekzy or stored anywhere.

Find More Useful Tools

Explore Brekzy's growing collection of free calculators, converters, AI tools, and practical resources.