Skip to content

XML formatter and XPath tester

Runs on your device

Pretty-print, minify and validate XML, and run XPath queries against it, in your browser.

Output
Indent

How to use XML formatter and XPath tester

  1. Paste the XML: a feed, a sitemap, a SOAP message, a config file.
  2. Choose pretty or minified output; the tool reports whether the XML is well-formed.
  3. Optionally type an XPath expression to pull out matching elements or values.

Readable XML, and whether it's valid

XML still runs a great deal of the world's plumbing: RSS and Atom feeds, sitemaps, SOAP APIs, invoices and e-invoicing standards, Office documents, Android layouts, Maven builds and countless configuration files. It often arrives as one long line from an API or a log. Paste it here and it comes back indented, one element per line, with elements that hold only text kept on a single line so the structure is easy to scan.

The tool also tells you straight away whether the XML is well-formed, using the browser's own XML parser, and shows the first error it finds, such as a tag closed in the wrong order, an unescaped ampersand or a missing quote. Comments, CDATA sections, processing instructions and the doctype are kept exactly as written.

Minify for transport

Switch to minified output to remove the whitespace between tags and, if you like, the comments, which makes payloads smaller for APIs and storage. Text inside elements keeps its words; only runs of spaces are collapsed. Formatting then minifying gives back the original document, so you can safely move between the two.

XPath queries

XPath is the query language for XML: //item/title finds every item's title, //product[@price > 100] filters by an attribute, count(//entry) counts. Type an expression and the matching elements, attributes or values appear underneath as you type, which makes it a quick way to test an expression before you put it in code or a scraper.

Documents with a default namespace, such as Atom feeds and XML sitemaps, need a prefix for their elements in XPath. The tool maps the default namespace to ns:, so //ns:url/ns:loc finds every address in a sitemap.

Private and safe

Everything runs in your browser and nothing is uploaded. The parser doesn't fetch external entities or DTDs, so pasting a malicious document can't make it load files or contact other servers.

Questions

What does well-formed mean?
That the XML follows the basic syntax rules: every tag is closed, tags nest properly, attribute values are quoted and special characters are escaped. The tool checks this with your browser's own XML parser and shows the first error it finds.
How do I query a document with a namespace?
When the root element declares a default namespace, as Atom feeds and sitemaps do, elements must be written with a prefix in XPath. The tool maps the default namespace to ns:, so //ns:entry/ns:title works; prefixes the document declares itself work as they are.
Is my XML uploaded?
No. Formatting, validation and XPath all run in your browser. The parser also never fetches external entities, so a hostile document can't make it load anything.