Nodes/honda-nodes/πŸ“‘ JSON Merge
ComfyUI Node

πŸ“‘ JSON Merge

Fold two JSON blobs into one, the way jq would

By AvarayΒ·Created 14 days agoΒ·Updated 12 days agoΒ· 0
πŸ“‘ JSON Merge
    • Result
    β—„json_a{}β–Ί
    β—„json_b{}β–Ί

    Sooner or later you end up holding a JSON string inside a graph and needing to modify it without throwing away the rest. Usually it's metadata: you pulled the embedded blob out of a PNG, you want to add your own fields to it (a run name, a client, a seed you care about), and then hand the result to something that writes it back into a file. In a terminal that's a one-liner with jq. In ComfyUI it used to be a Python node you wrote yourself. This is that node, already written.

    How it works

    JSON Merge isn't a hand-rolled Python dict merge. It shells out to jq, and the actual command is jq -s '.[0] * .[1]' with both strings piped in on stdin, newline-separated. The -s flag slurps the two documents into a single array, so .[0] is your JSON A and .[1] is JSON B. Then * does jq's recursive object multiply: keys present in only one side are kept, keys present in both are merged if both values are objects, otherwise B wins.

    That last part is the whole personality of the node. It's a deep merge for objects - nesting two levels down merges two levels down rather than clobbering the parent - but it is not a deep merge for arrays. Two arrays in the same key don't concatenate or union; B's array replaces A's outright. If you were hoping to append a tag to a list that's already there, you'll want JSON Set Key on the array's index instead, or accept that you're overwriting.

    Both fields default to {}, and a blank or whitespace-only string is coerced back to {} before it hits jq - so an empty string in either socket gives you the other side unchanged instead of an error. Both inputs are multiline; convert the widgets to inputs (right-click β†’ Convert to input) to feed them from upstream.

    The inputs and outputs that matter

    You set two things: JSON A (the base object) and JSON B (the object whose keys overwrite A's). That's it - there is nothing to configure, no merge mode, no strategy selector.

    The single output, Result, is a STRING holding valid JSON. jq pretty-prints with two-space indentation, which looks odd if you're used to compact JSON but parses identically everywhere downstream. Typical landing spots: the metadata input on Save Image, the JSON Data input on JSON Set Key if you've got more edits to make, or a Text/JSON Preview node when you just want to see what merged.

    A concrete pairing worth stealing: Load Image emits a Metadata string that is the image's existing embedded JSON. Feed that into JSON A, put {"custom": {"run": "batch_07"}} in JSON B, and you've amended someone's metadata without hand-parsing anything.

    How to install it

    The node ships in Avaray/honda-nodes, which is in the ComfyUI Registry - open ComfyUI Manager β†’ Node Pack β†’ search Honda Nodes β†’ Install β†’ restart. Manually:

    cd ComfyUI/custom_nodes
    git clone --depth 1 https://github.com/Avaray/honda-nodes.git
    cd honda-nodes
    python install.py
    

    Use the Python that ComfyUI itself runs with - on Windows portable that's ..\..\..\python_embeded\python.exe install.py from inside the pack folder, otherwise your venv's python. install.py is not optional here: it downloads the jq binary (and ime, used by the pack's image/metadata nodes) into the pack's own bin/ folder. No pip packages beyond the ComfyUI frontend package, no model downloads.

    Common issues

    "The 'jq' CLI tool was not found in the system PATH or the extension's 'bin' folder." That's the node's own error text, and it means install.py never ran or its download failed. It happens if you cloned the repo and skipped step two, if ComfyUI Manager's install didn't execute the installer script, or if the machine was offline / behind a proxy when it tried to reach GitHub releases. Run install.py by hand and restart. If jq is already on your PATH - Linux, WSL, most package managers - the node finds that first and you never need the local copy.

    A merge throws instead of returning something. The error is jq's stderr relayed back at you, so read it literally. Almost always one side isn't JSON at all - a truncated paste, a trailing comma, NaN from a Python json.dumps, or an A1111-style parameters block, which is plain text. Run both sides through JSON Validate and you'll find the culprit in one run instead of five.

    Your array vanished. Not a bug - * replaces arrays. If both sides have a key holding a list, B's list is the result.

    One honest caveat about the pack: honda-nodes shipped in October 2026, so there's essentially no community track record to lean on if something looks wrong. Not a knock - the code is plain and readable - but "check the GitHub issues" gets you less than it would for a two-year-old pack.

    Category⚑️ Honda Nodes/πŸ“‘ JSON

    Inputs (2)

    NameTypeDefaultDescription
    json_aSTRING{}The first JSON object.
    json_bSTRING{}The second JSON object. Its keys will overwrite keys in JSON A.

    Outputs (1)

    NameTypeDescription
    ResultSTRINGβ€”