JsonPathExists (Yogurt Nodes)
Ask 'is this key there?' before you try to read it
- json_data
- exists
API responses are not guaranteed to have the same shape twice. Sometimes the field you need is there, sometimes the service quietly dropped it, sometimes it's nested one level deeper than last week. JsonPathExists is the defensive check: give it a JSON object and a path, and it returns a clean BOOLEAN - True if the path is present, False if not - so your workflow can branch on reality instead of crashing on assumptions.
It's a logic node in the YogurtNodes pack (yogurt7771/ComfyUI-YogurtNodes), and it's the natural companion to JsonGetPath and JsonSetPath. Think of it as the graph-native version of if 'key' in data - except it works on dotted paths through nested structure, not just top-level keys.
How it works
Same JSONPath-style path language as the other get/set nodes: $ for root, .key to descend, [0] to index into arrays. So $.data.seed checks whether data exists and has a seed key; $.items[2].name checks whether items has at least three elements and the third has a name. If any step along the path is missing - a key that isn't there, an array index that's out of range, a type mismatch where you expected a dict but found a string - the answer is False.
The input also accepts a JSON string directly, which is handy when you have raw text and just want to know "does this contain that path?" before bothering to parse it.
Inputs that matter
json_data- the object or string to inspect.path- the JSONPath expression to check. Defaults to$, which is basically alwaysTruefor a non-empty object; you'll be typing a real path.
Output: exists, a BOOLEAN.
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
- "It says False and I can see the key." Path typo - a missing dot or a wrong index - is the usual cause. And remember the path engine is a pragmatic subset: dotted keys and integer indices. A key containing a dot needs bracket notation (
['a.b']) or the parser reads it as a separator. - "But the key exists with a null value!"
{"a": null}- is path$.a"there"? Yes, it exists (the key is present); the value is justNone. Existence and non-null are different questions. If you need "present and not null," check with GetPath and an IsEmpty/not-null check instead. - "It exists now but might not later." That's the whole point of the node - wire the
existsoutput into a Switch so the graph takes one branch when the field is present and a fallback when it isn't, instead of a hard failure mid-run.
The clean pattern: PathExists → branch → only then GetPath. You never read a path you haven't confirmed, and upstream API drift stops being a workflow-crash event. Cheap insurance for anything that ingests external JSON.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| json_data | * | JSON object or string | |
| path | STRING | $ | JSONPath expression to check |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| exists | BOOLEAN | — |