XML formatter and validator
Paste XML to indent it neatly, shrink it to one line, or find out why it is broken. If the document is not well-formed, you get the line and column of the first problem.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- Paste XML into the left box.
- Choose an indent of 2 or 4 spaces or a tab, or Minify to remove the extra whitespace.
- Copy the result. If the XML is broken, the error shows the line and column instead.
What is checked
- One root element, and nothing but whitespace, comments and processing instructions around it.
- Every start tag has a matching end tag, nested correctly.
- Attribute values are quoted and an attribute name is not repeated in one tag.
& in text or attributes starts a reference (&, A), never stands alone.
- Comments, CDATA sections, processing instructions and a DOCTYPE are recognised and kept as they are.
Example
<a><b></a> is reported as: the closing tag is </a> but <b> is still open.
Tips
A text-only element such as <title>XML Basics</title> stays on one line; an element with children gets one line per child. Empty elements keep the form you wrote, <a/> or <a></a>.
Frequently asked questions
What does "well-formed" mean?
It means the document follows XML's syntax rules: one root element, every start tag closed in the right order, attribute values in quotes, no repeated attributes, and "&" and "<" written as entities in text. This tool checks exactly that.
Does it validate against a DTD or schema?
No. It checks well-formedness only. Validating against an XSD or DTD needs the schema and a dedicated validator.
Does formatting change my data?
Tags, attributes and text are kept as written. Only whitespace between elements changes. In mixed content such as <p>Hello <b>world</b></p> the text pieces are placed on their own lines, so run the result through a parser, not a diff, if exact spacing matters.
What does minify remove?
Whitespace-only text between tags, and optionally comments. Text with real characters is left alone, including its inner spaces.
Is my XML sent to a server?
No. The check and formatting run in your browser.