Nodes/Duanyll Nodepack/JSON Path Query Single
ComfyUI Node

JSON Path Query Single

Get one value out of JSON — the unwrapped sibling of JSON Path Query

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

JSON Path Query Single is the little sibling of the pack's JSON Path Query node, and the difference is one word: single. Instead of returning every match as a list, it returns just the first match, unwrapped - the raw value, not a one-element list around it. When you know a query should hit exactly one thing, this is the node that keeps your graph clean.

When to reach for it

Most of the time when you extract from JSON, you're after one specific field: the width from an API response, the seed the LLM picked, the label of the first detection. That's this node's lane. JSON Path Query (plural) is for when you want all matches collected into a list for batch processing - think "every item in an array." The mental rule: one thing you want to wire into a single-value socket → Single; a pile of things you want to iterate → the regular one.

How it works

Same engine as its sibling - the jsonpath-ng library - and the same inputs:

  • json_data - any JSON-able value (wildcard socket).
  • query - the JSONPath expression.
  • raise_errors (default false) - if a query fails, either raise (debug mode) or return None (graceful mode).

The one behavioral difference is in the code: it evaluates the query and returns matches[0] - the first result only. No matches means None (or an error if raise_errors is on). If your query legitimately returns several things and you take only the first, that's on you - it's exactly what "single" means here.

Output is a single wildcard value. Note the type is whatever the matched value is - a string, a number, even a nested dict if your query lands on one. It's not coerced, so wire it to a socket that can accept the actual type.

Installing it

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

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

The jsonpath-ng dependency ships with the pack's requirements. The node is under duanyll/data.

The usual pipeline: parse some JSON (the pack's Parse JSON5 or its LLM-output parser), pull out the one field you care about with this node, and feed it to a text display, a KSampler seed, or whatever expects a concrete value. It's a small node, but it's the one that makes "get the value out of the blob" a two-node job instead of a script.

Categoryduanyll/data

Inputs (3)

NameTypeDefaultDescription
json_data*
querySTRING
raise_errorsoptBOOLEANfalse

Outputs (1)

NameTypeDescription
**