Nodes/ComfyUI-YogurtNodes/JsonGetPath (Yogurt Nodes)
ComfyUI Node

JsonGetPath (Yogurt Nodes)

Pull one value out of a JSON blob with a path, not a pile of nodes

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
JsonGetPath (Yogurt Nodes)
  • json_data
  • default_value
  • value
path$
use_defaultfalse
raise_on_errorfalse

The moment your API response or metadata blob comes back as nested JSON, you have two options: build a chain of dict-access nodes, or write a path. JsonGetPath is the path option. Give it {"users": [{"name": "ada", "age": 36}]} and the path $.users[0].name, and it returns "ada". One node, one string, done.

It's a logic node in the YogurtNodes pack (yogurt7771/ComfyUI-YogurtNodes), from the pack's JSON family (parse, stringify, merge, set path, path-exists). If you're feeding API payloads into a workflow - a webhook result, an LLM node's structured output, an image-generation service's metadata - this is how you get the one field you actually care about into a wire.

How it works

It parses a JSONPath-style expression. The syntax you'll use 95% of the time:

  • $ - the root.
  • .key or ['key'] - descend into an object. $.a.b.c.
  • [0] - index into an array. $.items[2].

So $.data.seeds[0].seed walks to the data object, then seeds, then the first element, and returns its seed. It's worth knowing the path engine here is a pragmatic subset of the JSONPath spec - dots, bracket keys, and integer indices - not the full wildcard/branching language. If you need $..find-all-anywhere, this isn't the tool; keep your paths explicit.

The node also accepts a JSON string as json_data, so you can skip a parse node if all you want is one field out of raw text.

Inputs that matter

  • json_data - object or string.
  • path - the JSONPath expression. $ alone returns the whole thing, which is a decent "is this wired up right" sanity check.
  • use_default + default_value - return a fallback instead of None when the path doesn't exist.
  • raise_on_error - flip on if a missing path should hard-fail the workflow rather than silently returning None. Good for catching typos in paths during development.

Output: value - whatever lives at that path.

Install

Pack-wide routine - ComfyUI Manager (search "YogurtNodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
cd ComfyUI-YogurtNodes
pip install -r requirements.txt

Restart, find it under Yogurt Nodes / Logic. No extra dependencies.

Troubleshooting

  • "Returns None and I know the key is there." Most likely a path typo - a missing dot, a wrong index, or a key with a . in its name (which collides with the separator). If keys contain dots, bracket notation ['weird.key'] is your escape hatch; the parser handles escaped \. too.
  • "Array index out of range." [5] on a 3-item list gives you None (or your default). Combine with a length check or JsonPathExists if you can't trust the data shape.
  • "Whole object came back instead of a value." A path that stops mid-tree returns the subtree, not a leaf. $.data returns the whole data dict - which is correct, just usually not what you wanted.
  • Defaults vs. errors. Leave raise_on_error off while developing (silent None is easier to debug than a hard crash mid-graph), then flip it on for production to catch shape changes in upstream data.

If you've got a growing pile of these, the sibling JsonPathExists tells you whether a path is present before you read it, and JsonSetPath writes values back. Together they're a small but complete "query a JSON blob" toolkit.

CategoryYogurtNodes/Logic

Inputs (5)

NameTypeDefaultDescription
json_data*JSON object or string
pathSTRING$JSONPath expression (e.g., $.users[0].name)
default_valueopt*Default value if path not found
use_defaultoptBOOLEANfalseReturn default value instead of None
raise_on_erroroptBOOLEANfalseRaise error if path not found

Outputs (1)

NameTypeDescription
value*