Search tools

Find a tool by name or what it does.

XPath Tester

Run an XPath expression against XML or HTML and see every matching node, with its name, text, and full markup.

Results update live as you type. Nothing leaves your browser.

Try
Results

Paste a document to test an expression against.

Quick reference
//bookEvery book element, at any depth.
/library/bookBook elements directly under the root library.
//book[@id="2"]Filter by an attribute value.
//book[2]The second book among its siblings.
//book/@genreThe genre attribute node itself.
count(//book)A number rather than a node set.
//title/text()The text node inside each title.
//*[local-name()="item"]Match by name while ignoring namespaces.

How to test an XPath expression online

  1. Paste your document

    Drop XML or HTML into the document field and pick which of the two it is.

  2. Write the expression

    Type an XPath expression. It is evaluated live, and a syntax error appears under the field with the exact reason.

  3. Read the matches

    Every matching node is listed with its name, node kind, text content, and serialized markup, along with a total count.

  4. Copy the results

    Copy the matched markup to your clipboard in one click.

Why use this tool

XML and HTML

Switch between strict XML parsing and forgiving HTML parsing, so you can test against a feed, a config file, or a scraped page.

Full node detail

Each match shows its node name, whether it is an element, attribute, text, or comment, its text content, and its full markup.

Not just node sets

Expressions that return a number, a string, or a boolean are handled too, so count, string-length, and contains all work.

Clear parse errors

A malformed document reports the parse message instead of silently returning nothing, and an invalid expression reports its own error inline.

Namespace prefixes resolved

Prefixes declared anywhere in an XML document are collected automatically, so an expression using them matches without extra setup.

Runs entirely in your browser

Documents are parsed on your device. Nothing is uploaded, so internal feeds and API responses stay local.

About this tool

XPath is the query language for XML, and the fastest way to understand an expression is to run it. Paste a document, type an expression, and this tester shows every matching node the moment you stop typing: the node name, whether it is an element, an attribute, a text node or a comment, the text it contains, and the markup itself. A running count sits above the list so you can tell a selector that matched three things from one that matched three hundred.

It handles the parts that usually go wrong. A document with an unclosed tag or a stray ampersand reports the parse message rather than quietly matching nothing, so you fix the document instead of blaming the expression. An expression with a typo reports its own error under the field. Expressions that do not return nodes at all are supported as first class results: count gives you a number, string and concat give you a string, and a predicate on its own gives you a boolean. Namespace prefixes declared anywhere in the document are collected and resolved, which is the usual reason an expression that works in one tool returns nothing in another.

HTML mode uses forgiving parsing, so a fragment copied out of a page works even when it would never pass as XML. That makes it useful for planning a scrape before writing any code. Results are capped at the first 200 nodes with a note when the list is cut off, so a broad expression on a large document cannot lock up the page. Everything runs on your device and nothing is uploaded. For related work, the XML formatter makes a minified document readable first, XML to JSON converts once the shape is clear, and the JSON path finder does the same job for JSON payloads.

Frequently asked questions

Which XPath version does this support?
The version built into every browser, which covers XPath 1.0: axes, predicates, node tests, and the standard function library such as count, contains, starts-with, string-length, and local-name. XPath 2.0 and 3.1 features like for expressions and sequence types are not available.
Can I use it on HTML as well as XML?
Yes. Switch the document type to HTML and the markup is parsed the forgiving way a browser parses a page, so unclosed tags and missing quotes still produce a usable tree. XML mode is strict and reports the first parse error instead.
Why does my expression return nothing on a namespaced document?
Usually because the document declares a default namespace, which an unprefixed name in XPath 1.0 will not match. Prefixes declared in the document are resolved for you, but for a default namespace use a name test such as //*[local-name()="item"].
What happens with an invalid expression or a broken document?
Both are reported rather than swallowed. An expression that will not compile shows its error under the expression field, and a document that fails to parse shows the parse message in the results area, so you always know which of the two is at fault.
Is there a limit on how many matches are shown?
The list shows the first 200 matching nodes and tells you when it has been cut off, while the count above it reflects every match. Very long text and markup on a single node are trimmed so one huge node cannot dominate the page.
Is my document uploaded anywhere?
No. Parsing and evaluation run entirely in your browser. The document never leaves your device, is never sent to a server, and is not stored or logged.

Related tools