π JSON Set Key
Change one field inside a JSON blob, keep everything else
- Result
The scenario: an image arrives with metadata already in it, and you want to add or correct one field - stamp your workflow name in, overwrite a title, tag the batch - without reconstructing the whole JSON object. Rebuilding it by hand in a Text node means pasting the entire blob and hoping you didn't break a brace. JSON Set Key does the surgical version.
How it works
Under the hood it builds a jq invocation: either --arg val "<your value>" or --argjson val <your value>, followed by an expression like .metadata.title = $val, with the JSON piped in on stdin. jq applies that path assignment to the document, creates missing intermediate objects on the way down, and prints the whole document back out.
Two behaviours of that pipeline are what you actually need to know.
The path is jq syntax, not a plain key name. .title, .metadata.title, .custom.PngText.workflow, .items[0].name. If you type a bare title the node quietly prepends the dot for you (it checks whether the first character is alphanumeric), so the simple case just works - but anything with an index or a quoted key has to be spelled properly. If you don't know the path, put a JSON Preview node upstream, click the copy-path button next to the field, paste it here.
The string-versus-JSON switch is a real switch. With Is JSON/Number? off (the default), your value is passed through --arg, which means it lands in the document as a JSON string. Set 42 and you get "42", quotes included, which will annoy anything downstream expecting a number. Flip the switch on and it uses --argjson, which parses your value as JSON - so 42 becomes a number, true becomes a boolean, {"a":1} becomes a nested object. The flip side: with the switch on, the value has to be valid JSON. hello bare will fail; "hello" with quotes works. Empty value plus the switch on becomes null rather than an error.
The inputs and outputs that matter
Four inputs. JSON Data - the blob to modify, multiline, defaults to {}. Key Path - the jq path, defaults to .new_key. Value - the thing you're setting. Is JSON/Number? - the type switch above, and the one field people get wrong.
One output: Result, pretty-printed valid JSON. Feed it to Save Image's metadata input, or into another JSON node if you've got several fields to write (chain them; each one adds a key). For a run of edits, chaining three Set Key nodes reads better than one giant merge.
The most common real use is amending the metadata you just read off an image: Load Image's Metadata output β JSON Set Key (.custom.title = your title) β Save Image's metadata input. Round-trip, no Python.
How to install it
It's one of twenty-odd nodes in Avaray/honda-nodes, on the ComfyUI Registry as Honda Nodes (Manager β Node Pack β search β Install β restart). Manual:
cd ComfyUI/custom_nodes
git clone --depth 1 https://github.com/Avaray/honda-nodes.git
cd honda-nodes
python install.py
Run install.py with ComfyUI's own Python - Windows portable uses ..\..\..\python_embeded\python.exe install.py. It downloads the jq binary into the pack's bin/ folder, and this node is dead without it. No pip deps, no models.
Common issues
jq: invalid JSON text passed to --argjson. You turned Is JSON/Number? on and the value isn't valid JSON. Quote your strings, drop the trailing comma, or just turn the switch off if you wanted a string all along.
jq failed (exit code N) with a compile error. The key path didn't parse. Usual suspects: a leading $, an unquoted key containing a hyphen or space (.my-key is subtraction to jq - use . ["my-key"]), or an index into something that isn't an array.
"The 'jq' CLI tool was not found." The installer didn't run or its GitHub download failed (offline, proxy, rate limit). Re-run install.py and restart ComfyUI.
It worked, but the value came out as a string. By design - that's the default. Flip the switch.
The output is huge and indented. That's just jq's pretty printer; it's still valid JSON and every node downstream parses it fine. If you're eyeballing it, use JSON Preview instead of staring at the widget.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| json_data | STRING | {} | The JSON string to modify. |
| key_path | STRING | .new_key | The jq path for the key, e.g., '.metadata.title' or '.name'. |
| value | STRING | my value | The value to set. |
| is_json_value | BOOLEAN | false | Enable if the value is a number, boolean, or raw JSON object instead of a string. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Result | STRING | β |