Data & JSON

XPath Tester

Test XPath 1.0 expressions against HTML or XML with optional context nodes, element, attribute and text matches, plus count(), string() and boolean() results. Parses locally with copy and download.

About this tool

Paste an HTML or XML document, enter an XPath expression and inspect the matches immediately. The browser's native XPath 1.0 engine supports node sets, attributes, text, comments and scalar results such as count(), string() and boolean().

Select a context node with a second XPath before running relative queries. Input is never injected into the current page, scripts are not executed, and matched content is displayed as text.

Best use cases

  • Verify node paths copied from a webpage or XML API before using them in a script.
  • Confirm extraction expressions for crawlers, data conversion and browser automation.
  • Compare node counts and scalar return values while debugging filters and context paths.

How to use it

  1. Choose HTML or XML mode, paste a document and load the matching example if needed.
  2. Enter an XPath expression and optionally provide a context-node expression for relative queries.
  3. Test the expression, review node or scalar results, then copy or download the text output.

Scope and limits

  • Up to 200,000 document characters, 4,000 characters per expression and 200 displayed node matches.
  • Supports browser-provided XPath 1.0 only, without XPath 2.0/3.0 functions or a custom namespace resolver.
  • XML mode rejects DTD and entity declarations. Very large individual node values are truncated for display.

Data processing

Parsing and XPath evaluation use native DOMParser and document.evaluate in your browser. Documents are not uploaded, scripts are not executed, and results are rendered as safe text.

FAQ

Why does my expression match nothing?

Check the document type, tag case, namespaces, absolute or relative path and context node. HTML mode follows HTML parsing rules, while XML mode requires well-formed XML.

How do I use a context node?

Enter an XPath that selects one node, such as //catalog, then use a relative main expression such as book/title. A missing context match is reported explicitly.

Are scripts in the document executed?

No. The document is used only for local XPath evaluation, is not injected into the current page, and matches are displayed as text.

Related tools

More in this category