Loading Techie Utils…

JSONPath & XPath Expression Evaluator

Reduce a JSONPath or XPath match to a single answer. Free, and runs entirely in your browser — nothing you enter is uploaded, stored or sent to a server.

About Expression Evaluator

Where the Path Finder lists matches, the evaluator reduces them to one answer. Pick a function — count, sum, avg, median, min, max, product, range, first, last, distinct, sort, join, length, keys, values, paths or types — and it is applied to everything the expression selects.

The functions work the same way in every format, because they read the matched nodes rather than the document: a JSONPath match set and an XPath node set reduce identically. Choose matches when you want the nodes themselves rather than a reduction.

XML keeps its own function library as well. An XPath that already answers — count(//item), sum(//item/@qty), string-length(//title), boolean(//error) — is reported as it stands, and the result says the function was not applied, because there was nothing left to reduce.

Where it helps

  • Answers aggregate questions — how many, how much, what is the largest — without writing a script.
  • Twenty functions cover counting, arithmetic, ordering, sampling and key inspection.
  • The same functions apply to JSON, YAML and XML, so an XPath node set can be averaged or sorted as easily as a JSONPath match.
  • XPath's native function library is still available in full for XML.
  • Reports how many nodes matched alongside the answer, so an unexpected result is easy to diagnose.

Limits

  • Arithmetic functions ignore matches that are not numbers rather than failing, so check the matched count against what you expected.
  • The function applies to the whole match set; grouping and joins need a real query language.
  • XPath here is 1.0, so its own library has no max() or min() — select the nodes and let the function list reduce them instead.
  • Floating-point arithmetic applies, so summing money can produce the usual trailing-decimal artefacts.

Frequently asked questions

Why is my sum zero?

The path matched nodes that are not numbers — often objects rather than the field inside them. Check the matched count and narrow the path.

How do I count nodes in XML?

Either way works. Select them with //item and choose count, or write the XPath count(//item) and let the expression answer on its own.

What do sort and join compare?

Matches that all look numeric are ordered by size; anything else is ordered as text. join renders each match as a string and separates them with commas.

What does distinct return?

The unique values among the matches, compared structurally, so two identical objects count once.

Can I do arithmetic across two different paths?

Not here — evaluate each one and combine the answers yourself, or use a proper query tool such as jq.

Related tools

  • Path Finder — Select nodes with JSONPath or XPath
  • Table Viewer — Show the records in a JSON, XML, YAML, TOML or TOON document as a table
  • Tree Viewer — Explore JSON, XML, YAML, TOML, TOON or HCL as a collapsible tree
  • Structure Validator — Check JSON, XML, YAML, TOML, TOON or HCL and report structural problems
  • Structure Converter — Convert between JSON, XML, YAML, TOML, TOON, HCL and CSV
  • String Escaper — Escape a JSON, XML, YAML, TOML or TOON document for embedding, or read one back

More Structured Formats tools

  • Structure Converter — Convert between JSON, XML, YAML, TOML, TOON, HCL and CSV
  • String Escaper — Escape a JSON, XML, YAML, TOML or TOON document for embedding, or read one back
  • Structure Formatter — Pretty-print JSON, XML, YAML, TOML, TOON or HCL with a chosen indent
  • Structure Validator — Check JSON, XML, YAML, TOML, TOON or HCL and report structural problems
  • Tree Viewer — Explore JSON, XML, YAML, TOML, TOON or HCL as a collapsible tree
  • Code Generator — Turn a JSON, YAML, XML or other document into TypeScript, Go, C#, Python, Rust and more
  • Schema Generator — Write a JSON Schema, XSD, Avro schema or .proto from a document you already have
  • Schema Validator — Check a document against a JSON Schema, .proto, Avro schema, XSD or RELAX NG
  • Table Viewer — Show the records in a JSON, XML, YAML, TOML or TOON document as a table
  • Structure Compare — Diff two JSON, XML, YAML, TOML, TOON or HCL documents by path
  • Structure Repair — Fix broken JSON, YAML, XML, TOML, TOON, INI, .env, .properties and HCL, listing every repair
  • Structure Minifier — Strip formatting from JSON, XML, YAML, TOML or TOON
  • Path Finder — Select nodes with JSONPath or XPath
  • Protobuf & Avro Decoder — Read protobuf wire bytes and Avro container files without their schema