XML Formatter

Validate, pretty-print and minify XML, with XPath

Paste XML to validate and format.


How to format XML

  1. Paste XML into the editor: a SOAP response, RSS or Atom feed, sitemap, SVG, Android layout, Maven pom.xml or any other document.
  2. Press Format to indent it with 2 spaces, 4 spaces or tabs, or Minify to remove all whitespace between elements.
  3. If the XML is not well-formed, the parser's error message tells you what is wrong, such as a mismatched closing tag or an unescaped &.
  4. Optionally, type an XPath expression to pull out matching elements, attributes or values.

Validation and XPath

The formatter uses your browser's built-in XML parser, so it checks well-formedness exactly as other standard tools would: every tag must be closed, attributes must be quoted, there must be a single root element, and special characters must be escaped. Comments, CDATA sections, processing instructions and the XML declaration are kept. Elements without content are written as self-closing tags such as <notes/>, and simple text elements stay on one line for readability.

XPath is the query language for XML. Try //book/title to list all titles, //book[@id='b2'] to find one element by attribute, count(//book) to count elements or sum(//price) to add values. It is handy for checking selectors before using them in Python's lxml, Java, Selenium or an XSLT stylesheet.

Privacy

Parsing, formatting and XPath all run locally in your browser. Your XML is never uploaded.

What is the difference between well-formed and valid XML?

Well-formed XML follows the basic syntax rules, which this tool checks. Valid XML also matches a schema (XSD or DTD) describing which elements are allowed; that needs a schema validator.

Why do I get "entity not defined" errors?

XML only predefines &amp;, &lt;, &gt;, &quot; and &apos;. HTML entities like &nbsp; must be replaced with numeric ones such as &#160;.

Does XPath work with namespaces?

Default namespaces make plain XPath queries return nothing. Use local-name(), for example //*[local-name()='book'], to match regardless of namespace.

Made by BufferMint. We also design and build software products for founders. See our services →

Your files and inputs never leave your device; we only count anonymous visits.