XPath Tester Online
Run XPath On Your XML
This XPath tester online runs an expression on your XML and lists every match. It also shows a tree, turns XML into text and escapes strings. Nothing is uploaded.
- FreePrice
- XPath 1.0Version
- NoneSign-up
- NoneUploads
XPath Tester
Run XPath on your XML, open it as a tree, or turn it into text
Add some XML to test against.
- Matches
- 0
- Result
- -
- Nodes
- 0
Ready. Paste XML, type an XPath and the matches appear.
What An XPath Tester Online Does For You
XPath is a small language for picking parts out of XML. A good query saves you a long loop of code. But a wrong query returns nothing, and you do not know why. So testing first saves time.
This tester shows you why. First, paste your XML and type an expression. The matches appear at once, each with its full path and its value. Then click a match, and the tool jumps to that spot in your XML.
The engine follows XPath 1.0. That is the version browsers, Java, PHP, Python and most XML tools use. So a query that works here works in your code.
Besides testing, the page has three more jobs. It draws your XML as a tree, turns XML into plain text, and escapes or stringifies text. All four share one box, so you never paste twice.
Everything runs in your browser. Your XML never leaves your device. That matters, because XML files often hold orders, settings and private feeds.
XPath Evaluator Online With Clear Results
First, type an expression such as //book[price > 10]/title. Then the list shows each title that fits. Every row has a kind, a path such as /library/book[2]/title, and the text inside.
Also, if the result is not a list, you still see it. A query such as count(//book) gives a number. A query such as contains(., "XML") gives true or false.
This xpath evaluator online also explains problems. A typo shows the position of the mistake. A valid query that finds nothing gets a hint to check names and case.
For more detail, see: MDN guide to XPath.
Click A Match To Find It
Large XML files are hard to read. So each match is a button, and that helps a lot. Click it, and the tool selects that element in your text and scrolls to it.

This makes debugging fast. Then you see the query, the result and the source in one view. In fact, you can fix a query in seconds.
XML Tree Viewer
First, switch to the tree mode to see the shape of your XML. Each tag opens and closes. Attributes show next to their tag, and comments appear in grey.

The tree also counts elements, attributes and depth. So you learn how big the file is at a glance.
XML To Text Converter
Sometimes you only want the words. So the text mode strips every tag and keeps the text, one piece per line. You can join the pieces with a space, a tab or a comma.

Also, attribute values can come along. Then you can copy the result or save it as a text file. Finally, paste it into a report or a search index.
Escape, Stringify And URL Tools
The last mode handles strings. First, escape turns an ampersand or a less-than sign into an entity. Then unescape does the reverse. Next, stringify wraps text in quotes with safe escapes, and parse reads it back. URL encode and decode work too.

A Short XPath Cheat Sheet
One slash goes down one level, and two slashes search every level. So /library/book is exact, while //book finds a book anywhere.
An at sign picks an attribute, as in //book/@id. A dot means the current node, and two dots mean its parent.
Square brackets filter. A number picks a position, such as [2]. A test picks by value, such as [price > 10] or [@lang="en"].
Then add functions when you need them. For example, count() counts nodes, and contains() tests for a word. Also, text() returns the words inside a tag.
What XPath 1.0 Covers
First, you get all thirteen axes, such as child, descendant, parent and following-sibling. You also get predicates, unions and every XPath 1.0 function, such as count, sum, contains, substring and translate.
Also, a few helpers from later versions, such as lower-case and ends-with, work too. Namespace prefixes match as you write them. So a tag such as x:note needs the x: in your query.
Using The XPath Tester Online, Step By Step
Four steps take you from XML to the exact nodes you need.
- 1
Paste your XML
Paste it into the box, open a file, or try the sample. Errors show the line.
- 2
Type an expression
Write XPath, or click an example chip. The result updates as you type.
- 3
Read the matches
Each match shows its kind, its path and its text. Click one to find it in the XML.
- 4
Copy what you need
Copy the values, or copy the paths. Then use them in your code.
What This XPath Tester Does Differently
Many testers only print raw output. These are the extras.
Real XPath 1.0
All axes, predicates and functions, written by hand. No eval, and no browser engine to guess.
Click to find
Each match jumps to its spot in your XML.
Full paths
See paths like /library/book[2]/title for every node.
Four tools in one
Test XPath, view a tree, get plain text, and escape strings.
Helpful errors
Bad XML shows the line. A bad expression shows the position.
Nothing leaves your tab
Your browser does the work. We never see your XML, and we keep nothing.
Habits For Writing Better XPath
Short, exact queries break less often. These habits help.
- Start from the root. A path such as /library/book is exact. A path such as //book is quick but may match too much.
- Use attributes to pick. A test such as @id="b2" is stable. A position such as [2] breaks when the order changes.
- Mind the case. XML names are case sensitive. Book and book are different tags.
- Test with text(). Add text() to get the words inside a tag, not the whole element.
- Use count() to check. A quick count tells you if your query finds one node or a hundred.
- Keep predicates short. Long tests are hard to read. Split them into steps instead.
- Watch for namespaces. A tag with a prefix, such as x:note, needs the prefix in the query.
- Use normalize-space(). It trims and tidies text, so a stray space does not break a test.
- Prefer relative paths in loops. Inside a loop, start from the current node with a dot.
- Validate the XML first. A broken file gives no result. Fix the XML before you blame the query.
- Save good queries. Keep a list of working expressions next to your code.
Common XPath Mistakes This Tool Helps You Spot
Each of these returns nothing or the wrong thing. The tester makes them visible.
Wrong case in a name
Title does not match title. The tester says the query is valid but found nothing.
Forgetting the prefix
A namespaced tag needs its prefix. Without it, nothing matches.
Mixing up / and //
One slash goes down one level. Two slashes search every level below.
Counting from zero
XPath positions start at 1. So [1] is the first node, not the second.
Quotes inside quotes
Use single quotes inside a double quoted string, or the reverse.
Unclosed tags in the XML
A missing close tag stops the parse. The tester shows the line.
XPath Tester Questions People Ask
Is this XPath tester online free?
Yes. It costs nothing, needs no account and has no limits. It runs in your browser, so we have no server cost to pass on.
Is my XML uploaded anywhere?
No. Your browser reads the XML and runs the query. Nothing reaches this site, and we keep nothing. Closing the tab clears it all.
Which XPath version does it use?
XPath 1.0. It is the version browsers, Java, PHP and Python use. A few extras from later versions, such as lower-case, also work.
How do I select an attribute?
Use an at sign. For example, //book/@id lists every id. A test such as //book[@id="b2"] picks the book with that id.
How do I get the text of a tag?
Add text() at the end, such as //title/text(). Or use string(//title) to get one value as text.
What does // mean?
Two slashes search at any depth. So //book finds every book, wherever it sits in the file.
Why does my query find nothing?
The usual causes are case, a missing prefix, or the wrong level. The tester tells you when a query is valid but empty.
Does it handle namespaces?
It matches prefixes as you write them. So x:note finds a tag called x:note. Use local-name() to ignore the prefix.
Can it show a whole element?
Yes. Each match shows its text and its path. Click it to find the element in your XML.
What is the XML to text mode?
It removes every tag and keeps the words. You choose what separates the pieces, and you can include attribute values.
What do escape and stringify do?
Escape turns characters such as the less-than sign and the ampersand into entities. Stringify wraps text in quotes with backslash escapes, so you can paste it into code.
Are DOCTYPE entities expanded?
No. Only the five standard entities and numeric references are read. That keeps the tool safe from entity attacks.
How big an XML file can I test?
Up to a few megabytes, and about 200,000 nodes. Very heavy queries stop with a message instead of freezing the page.
How do I pick the second item?
Use a number in brackets. For example, //book[2] picks the second book under each parent. Wrap the search in parentheses, as in (//book)[2], to pick the second book in the whole file.
Can I test XPath on HTML?
Only on well-formed XML. HTML often has unclosed tags, which XML rules reject. Clean the HTML first, or close the tags, and then test.
Does it work on a phone?
Yes. The panels stack and the lists scroll. For long XML, a keyboard is still easier.
Handy Companions For XML Work
Testing is one step. These three tools handle the steps around it.
XML Formatter
Beautify, minify and validate XML with exact errors.
Open tool →XML to JSON Converter
Turn XML into clean, typed JSON.
Open tool →JSONPath Tester
Run a path on JSON and see every match.
Open tool →
Ready To Test An XPath?
Paste your XML, type an expression, and read the matches. The tester is free, needs no account, and keeps every byte on your device.