XPath Playground
Run XPath queries against your own XML or HTML and see the matching nodes right away. Shows each match with its path and value, handles namespaces, and comes with examples for the syntax you keep forgetting.
Everything runs locally in your browser. Your data never leaves your device.
Result
Namespaces
Prefixes an expression can use, mapped to the namespace URIs in the document.
This document declares no namespaces, so plain names like //book match right away.
XPath 1.0 has no default namespace. A document that starts with xmlns="…" puts every element in that namespace, and an unprefixed name like //book then matches nothing at all. Bind a prefix to the URI here and write //ns:book, or sidestep the whole thing with //*[local-name(.)='book']. The prefix is yours to pick, it does not have to be the one in the document. HTML pages need none of this.
Cheat sheet
Click any row to load a working expression for the book catalog sample.
Steps and paths
Predicates
Functions
Axes
Expressions run through the browser's own XPath engine, the same one behind $x() in devtools. That engine speaks XPath 1.0, so XPath 2.0 and 3.1 additions like matches(), tokenize() or for loops are not available.
Next steps
Send this tool's output straight into another tool.
Format code in JavaScript, TypeScript, JSON, JSON5, HTML, Vue, CSS, SCSS, LESS, Markdown, YAML, GraphQL, XML and SQL. Pick tabs or spaces, set the indent width, and format the input in place with one click.
Paste JSON to explore it as a collapsible, searchable tree, hide the fields you don't need, and see the structure it implies as a badge-annotated schema and a copyable TypeScript interface.
Convert text into every case at once: title case in the APA, AP, Chicago, MLA, Bluebook, AMA and NYT styles, sentence case, upper, lower, camelCase, snake_case, kebab-case and more.
Count words, characters, sentences, paragraphs, lines and more as you type, with estimated reading and speaking time.
Remove duplicate lines from a list or text, keeping the first occurrence. Optionally ignore case and whitespace, or drop blank lines too.
Replace text in two modes: plain find and replace all, or regular expressions with flag controls and capture group references like $1.