XPath Tester
Evaluates an XPath or CSS selector against XML or HTML and lists every matched node.
Runs an XPath 1.0 expression or a CSS selector against an XML or HTML document and shows every node it matched, with the absolute path to each. Evaluation is the browser’s own, so what you see here is what `document.evaluate` will do in your code.
XPath 1.0 expression
Document
Drop a file
Read in this tab only.
Results
Results appear here as you type.
How it runs
- · Evaluation is the browser’s
document.evaluate(XPath 1.0) andquerySelectorAll. The result typing — node set, number, string, boolean — the absolute path for each node, and the namespace-prefix handling are this tool’s. - · XML mode reads strictly and reports what is wrong; HTML mode reads leniently, the way a browser does. HTML normalises tag names to lowercase, so
//DIVis wrong and//divis right. - · In a document with a default namespace (
xmlns="…"), an unprefixed name matches nothing — that is XPath 1.0’s rule. Use the_prefix, as in//_:item. - · XPath 2.0 and 3.x functions (
matches,ends-with,lower-case) are not in any browser.contains·starts-with·translate·normalize-spaceare what 1.0 gives you. - · The document is read in this tab only and is not uploaded anywhere.
For JSON, the JSONPath tester or the jq playground is the right tool.
How to use it
Choose how the document is read
XML mode is strict and reports what is malformed. HTML mode is lenient the way a browser is, and normalises tag names to lowercase.
Write the expression
XPath or a CSS selector — the toggle switches which. The example buttons cover attributes, predicates, namespaces, comment nodes and the scalar-returning functions.
Read the result type first
XPath returns four kinds of thing, and only one of them is a node set. `count()`, `string()` and `boolean()` give you a single value, shown on its own rather than as an empty match list.
Common questions
My expression matches nothing and the document looks fine.
Almost certainly a default namespace. If the document has `xmlns="…"` on its root, XPath 1.0 says an unprefixed name matches nothing at all — you have to bind a prefix. Here that prefix is `_`, so `//item` becomes `//_:item`.
Why does `matches()` not exist?
Because browsers implement XPath 1.0 only. `matches`, `ends-with`, `lower-case` and the rest arrived in 2.0 and no browser has it. The 1.0 toolkit is `contains`, `starts-with`, `translate` and `normalize-space`.
XPath or CSS — which should I use?
CSS is shorter and enough for most scraping. XPath can walk upward (`..`, `ancestor::`), match on text content, and return numbers and strings, none of which a selector can do. This page runs both so you can compare them on the same document.
Does it fetch a page for me?
No. You paste or drop the document and it is read in this tab. Fetching would need a proxy — the browser will not let a page read another origin — and that proxy would see everything you tested.
Feed it from
XML Formatter & Validator
Indents XML and reports the line and column of the first well-formedness fault.
JSON ⇄ XML
Converts between JSON and XML with configurable handling of attributes, arrays and text nodes.
JSONPath Tester
Runs a JSONPath expression against a document and highlights the matched nodes as you type.
JSON Formatter & Validator
Pretty-prints, minifies and validates JSON, pointing at the exact line and column of a syntax error.
Next
These accept what this tool produces, so the result can go straight in.
HTML Beautifier & Minifier
Formats or minifies HTML, preserving inline elements and optionally collapsing whitespace.
JSONPath Tester
Runs a JSONPath expression against a document and highlights the matched nodes as you type.
JSON ⇄ XML
Converts between JSON and XML with configurable handling of attributes, arrays and text nodes.
XML Formatter & Validator
Indents XML and reports the line and column of the first well-formedness fault.
Base64 Encoder & Decoder
Encodes and decodes Base64 and Base64URL for text or files, handling UTF-8 correctly.
curl to Code
Converts a curl command into fetch, axios, Python requests, Go, PHP or PowerShell.