Toolyard

XML Formatter

How to format XML

  1. Paste your XML into the box.
  2. The indented version appears below as you type, with the element count and the size.
  3. Switch Output to "One line" to strip the indentation again, then copy or download the result.

Frequently asked questions

Is my XML checked for errors?

Yes. It is run through the browser's own XML parser, so anything that is not well formed, such as an unclosed tag or a stray ampersand, is reported with the line it is on.

Does formatting change the content?

Only the whitespace between elements. Attributes, comments, CDATA sections and entities come back exactly as the parser read them. Whitespace inside an element that also has child elements is dropped, which matters only if your format treats it as data.

Why has my self-closing tag changed?

An element with no children is written as <tag/>, which is the same thing as <tag></tag> in XML. Both are read identically by any XML parser.

Does it work with RSS, SVG and SOAP?

Yes. They are all XML, so a feed, an SVG drawing or a SOAP envelope can be indented or shrunk the same way.

What about HTML?

HTML is more forgiving than XML, so a page with unclosed <p> or <br> tags will be reported as an error here. Use the minifier for HTML instead.

Is my XML uploaded?

No. The text is processed inside your browser and is never sent anywhere.

More developer tools