Format or minify XML, browse it as a tree, run XPath and validate against an XSD or DTD
Indent XML so you can read it, or minify it onto one line. Broken XML gets the line, the column and the reason.
How to use it
Paste XML on the left, or open a .xml, .svg, .xsd or other XML file. Choose Format or Minify, the indent, and whether comments stay. Copy or download the result. Any error is marked in your text with its line and column. Pick Explore to fold the document as a tree, run an XPath expression, or Validate it against an XSD or a DTD; each line number takes you to that place in your text.
Examples
Indent a SOAP response
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetPriceResponse><Price>34.50</Price></GetPriceResponse></soap:Body></soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetPriceResponse>
<Price>34.50</Price>
</GetPriceResponse>
</soap:Body>
</soap:Envelope>A tag never closed
<config> <port>8080</port> <host>localhost </config>
Line 4, column 1Expected </host> but found </config>
The reason comes with the line and column, and the place is marked in your text.
What formatting changes, and what stays as written
Safe with untrusted XML
What it checks
A lone "&" isn’t allowed: write it as & (as in Tom & Jerry). Attribute values must be in quotes: write id="1", not id=1. Expected </a> but found </A>: names are case-sensitive, so the closing tag must match exactly. Only one root element is allowed: wrap the elements in one, such as <items>…</items>. <?xml …?> may only stand at the very start: delete any space or line before it.
Explore: tree, XPath and validation
Questions
- Can it read SVG, RSS, Android layouts or .csproj files?
Yes: they are all XML. Open the file or paste its text; the formatter reads any well-formed XML 1.0. - Why is one element left on a single line?
It holds text beside other elements (mixed content), or says xml:space="preserve". Adding line breaks there would change the text, so it is written as it came. - How do I validate XML against an XSD?
Paste the XML, pick Explore, then Validate, and paste the XSD in the box. Every problem is listed with its line and column, such as an element the schema doesn’t expect there, a missing required attribute, or a value outside its type (a date that doesn’t exist, a number above maxInclusive). A DTD works the same way, or leave the box empty to use the DOCTYPE in the document. - Which XPath does it run?
XPath 1.0: paths and every axis but namespace, predicates such as [@id="2"] and [last()], unions with |, comparisons and arithmetic, and the core functions (string, number and boolean ones such as concat(), substring-after(), normalize-space(), count() and sum()). Element names match as you write them, so a document with a default namespace works without a prefix. - Is my XML uploaded?
No. Everything runs in your browser, so your XML stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first. SOAP messages, config files and exports often hold passwords or keys, and the page warns you if it spots any.