XML formatter and validator
Format, minify or check XML syntax locally. A well-formed document can still fail an XSD or DTD validation elsewhere.
Runs entirely in your browser
- Input
- 0
- Output
- 0
- Change
- 0%
Input up to about 10 MB. It checks that XML is well-formed; it does not validate against a schema (XSD) or DTD.
How to format and validate XML
- Paste your XML into the box, or press Insert a sample.
- Choose 2 spaces, 4 spaces, tabs, or Minify to remove the whitespace between tags.
- If the XML is not well-formed you see the line and column of the first problem. Otherwise copy or download the result.
Pretty-printing XML without changing it
XML is picky about structure and relaxed about layout: between two tags you may put nothing, a space, or a hundred blank lines and the document means the same thing. That is why feeds, SOAP responses and exported configuration often arrive on one long line. Indenting each nested element makes the hierarchy visible and makes a line-by-line comparison possible.
Many formatters parse the document and write it back out, which can quietly rewrite things you did not ask them to touch: turning © into a literal character, changing quote styles, or reordering attributes. This tool reads the text with a tokenizer and re-uses each piece exactly as it was written, adding or removing only whitespace between elements. It then uses the browser's own XML parser to check that the result is well-formed.
Whitespace is the one place where XML is not always relaxed. In a paragraph such as <p>one <b>two</b> three</p> the spaces around the tags belong to the text, so moving or removing them would change what a reader sees. Elements that mix text and tags, and elements marked xml:space="preserve", are therefore never reflowed.
Tips
- Moving data between formats? Pair this with the JSON formatter to read both sides.
- Formatting a web page rather than a data file? Use the HTML formatter, which understands void tags like
<br>. - Want to see what changed between two exports? Format both, then compare them in Text diff.
Reference: XML syntax and well-formed documents.
Questions
Does formatting change my data?
Tags, attributes and text are copied exactly as written. Entities such as & and ©, CDATA sections, comments, processing instructions and the DOCTYPE are not re-encoded or re-ordered. Only the whitespace between elements changes.
What happens to text mixed with tags?
An element such as <p>Hello <b>world</b></p> mixes text and elements, where every space can matter, so it is left exactly as written. The same goes for any element marked xml:space="preserve". A note under the result says how many were left alone.
What is the difference between well-formed and valid?
Well-formed means the syntax is right: tags closed and nested properly, attributes quoted, one root element. Valid means it also follows a schema or DTD. This tool checks the first; it reports a missing closing tag or an unquoted attribute but not an element your schema does not allow.
Why does it reject an HTML entity like &nbsp;?
XML itself defines only five named entities: &, <, >, " and '. Others, including , need a DOCTYPE that declares them, or a numeric form such as  .