Merge JSON Node [LP]
Merge JSON Node [LP] — ComfyUI Node Guide
- json_string
Two JSON strings in, one merged JSON string out, with a widget deciding what happens when both sides have the same key. This is the node you reach for when you've got a base config and an override, or two partial datasets, and you need them combined without hand-writing the merge logic yourself.
What it's for
JSON merging shows up in ComfyUI workflows more than you'd think once you start threading config through as data instead of hardcoding every widget - a base settings object plus a per-run override object, or two branches of a workflow that each built up part of a larger structure and now need to come back together into one blob before the next step reads it. Doing that by hand with string nodes is painful; this node exists so you don't have to.
It's part of the JSON toolkit this pack shipped as a batch - Get JSON Value, Check JSON Key, Get JSON Length, Stringify JSON - with some of the group's origin credited in the README to Comfyui-Simple-Json-Node by Q-Bug4.
Inputs and outputs
json_string_1(STRING, multiline) - the base JSON.json_string_2(STRING, multiline) - the JSON to merge in.merge_strategy- one of three options:- override - where both sides have the same key,
json_string_2's value wins. - preserve - where both sides have the same key,
json_string_1's original value is kept andjson_string_2only fills in what's missing. - concat - combine values at shared keys rather than replacing one with the other (the natural read for this option is that matching keys holding lists or strings get joined together instead of one clobbering the other).
- override - where both sides have the same key,
Output: json_string (STRING) - the merged result.
Which strategy you want depends entirely on the direction of your merge. If json_string_2 is meant to be a set of overrides on top of a base config, use override. If json_string_1 is your source of truth and json_string_2 is just there to fill gaps, use preserve. If you're combining two partial lists or accumulating values rather than replacing them, reach for concat.
Installing it
ComfyUI Manager: search "ComfyUI-LevelPixel" (shows up as "Level Pixel"), install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/LevelPixel/ComfyUI-LevelPixel.git, restart ComfyUI. No models, no heavy dependencies for this one.
Common issues
Both inputs need to be valid JSON independently before merging even starts - if either string fails to parse, expect the node to fail rather than merge what it could. Validate each side separately in a JSON linter if you're not sure which one's causing the error.
The strategy you pick matters more than it looks like at a glance, and picking the wrong one is the most common way this node "doesn't work" when it's actually working exactly as configured - if you expected an override to happen and you had preserve selected instead, your json_string_1 values will look like they're "sticking" and refusing to update, which is the setting doing its job, not a bug.
concat's behavior depends on what type of value is actually sitting at the shared key - concatenating two objects (dicts) isn't the same operation as concatenating two lists or two strings, so if your JSON's structure is inconsistent between the two inputs at a given key, double check the result actually did what you expected rather than assuming it did. When in doubt, run it once and eyeball the output with Stringify JSON from this same pack before wiring it deeper into your workflow.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| json_string_1 | STRING | — | |
| json_string_2 | STRING | — | |
| merge_strategy | COMBO | override | 3 options: override, preserve, concat |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| json_string | STRING | — |