TanodTools

XML formatter and validator

Paste XML to indent it, shrink it or check that it is well-formed, with the line and column of any error.

Runs entirely in your browser

Layout

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

  1. Paste your XML into the box, or press Insert a sample.
  2. Choose 2 spaces, 4 spaces, tabs, or Minify to remove the whitespace between tags.
  3. 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.

Questions

Is my XML uploaded?

No. The document is checked and formatted by code running in your browser, so configuration files, feeds and API responses stay on your device.

Does formatting change my data?

Tags, attributes and text are copied exactly as written. Entities such as &amp; and &#169;, 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 does Minify remove?

Only whitespace-only text between tags, such as line breaks and indentation between elements. Text inside elements, mixed content and preserved elements are untouched, so the minified file means the same as the original.

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 &amp;nbsp;?

XML itself defines only five named entities: &amp;, &lt;, &gt;, &quot; and &apos;. Others, including &nbsp;, need a DOCTYPE that declares them, or a numeric form such as &#160;.