JSON Path Update
Set a value deep inside a structure without touching the rest
- json_data
- value
- *
Reading values out of JSON is one thing; changing a value deep inside a structure is where most ComfyUI users end up writing Python. JSON Path Update is the node that does the edit for you: give it a JSON value, a JSONPath expression, and a new value, and it hands back a modified copy with just that spot changed - original untouched.
How it works
It's a thin wrapper around jsonpath-ng's built-in update behavior. The critical detail is in the implementation: the input is deep-copied before the update runs, so the object you feed in is never mutated. That matters more than it sounds - ComfyUI passes values by reference through the graph, and a node that mutates its input in place can corrupt data that another branch of your workflow is still using. This node deliberately doesn't do that, which is the sign of someone who's been burned.
The update walks the path and writes your value wherever it matches. So with {"cfg": 7, "steps": 20} and a query of $.cfg and value 10, you get {"cfg": 10, "steps": 20} back.
Inputs and outputs
json_data- the structure to edit (wildcard socket; dict or list).value- the replacement value (wildcard socket, so it can be a string, number, nested dict, list, whatever).query- the JSONPath expression locating the spot to change.
Output: the modified copy, same type as the input. Wire it into the next stage of your pipeline.
Where this earns its keep
The classic case is config-templating: you have a base JSON config (sampler settings, API payload, prompt template) and you want to swap one field per run - seed, size, a flag - without rebuilding the whole structure. This node is also handy after an LLM hands you JSON you want to fix up before it flows into the next node.
Two notes from the code: there's no raise_errors switch here, so a bad query will throw and stop the run - keep queries simple, or debug them on the query nodes first. And remember it replaces, it doesn't insert-or-create. If the path doesn't already exist, the behavior is "find nothing, change nothing," so make sure the field is actually there.
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 is in the pack's requirements, so it installs automatically. Find it under duanyll/data.
Honestly, if all you're doing is "set one top-level field," a core text-swap node might be overkill-avoiding. But once the value you need to change is nested two or three levels down, this is the node that saves you from building a JSON assembly pipeline.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| json_data | * | — | |
| value | * | — | |
| query | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |