Nodes/Duanyll Nodepack/JSON Path Query
ComfyUI Node

JSON Path Query

Pull every match out of a JSON object with a JSONPath query

By Duanyll·Created about a year ago·Updated 4 months ago· 2
JSON Path Query
  • json_data
  • *
query
raise_errorsfalse

The moment your workflow starts handling real data structures - LLM JSON output, API responses, metadata blobs - you'll hit the problem this node solves: you have a dict or list flowing through your graph and you need specific values out of it, deep inside the nesting. JSON Path Query runs a JSONPath expression against any JSON-ish value and hands you every match as a list, which makes it the extract-all-workhorse of the pack's JSON nodes.

How it works

It uses the jsonpath-ng library, which implements the standard JSONPath query language. The syntax will feel familiar if you've ever used XPath or JMESPath: a dot walks into objects, brackets index into arrays, .. is a recursive descent, [*] iterates all elements. A few examples against {"items": [{"name": "a"}, {"name": "b"}]}:

  • $.items[*].name["a", "b"]
  • $..name["a", "b"] (recursive descent)
  • $.items[0][{"name": "a"}]

The key behavior: the output is always a list, even when the query matches a single value. That's the design contract here - it makes the output safe to wire into batch-processing nodes, but it's also the difference between this node and its sibling JSON Path Query Single, which returns just the first match unwrapped. Pick based on what the downstream node wants.

Inputs and outputs

  • json_data - any JSON-able value (dict, list, string from a parse node). The socket is wildcard, so it accepts whatever flows in.
  • query - the JSONPath expression.
  • raise_errors (default false) - whether a bad query or a parse failure should raise and stop the run, or silently return an empty list. Turn it on while debugging; off (the default) when you want a failed lookup to degrade gracefully.

Output: a single wildcard output (a list) holding all matches.

Installing it

It's in Duanyll Nodepack. ComfyUI Manager → search "Duanyll Nodepack" → install → restart, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack

The jsonpath-ng dependency is in the pack's requirements, so it comes along automatically. The node lives under duanyll/data.

Typical wiring: Parse JSON5 (or the pack's LLM-output parser) into this node's json_data, query out the field you need, and feed the result onward. And if your query is wrong, raise_errors is your friend - the silent-empty-list default can send you chasing a bug that's actually just a typo in your path.

Categoryduanyll/data

Inputs (3)

NameTypeDefaultDescription
json_data*
querySTRING
raise_errorsoptBOOLEANfalse

Outputs (1)

NameTypeDescription
**