Merge Json
Combine two JSON strings without writing the merge logic yourself
- merged_json
A small, focused node: two JSON strings in, one merged JSON string out, with a strategy dropdown to control what happens when both sides define the same key. This node ships with no description at all in its schema - no explanation of exactly how each strategy behaves - so treat the read below as the reasonable interpretation of the strategy names, worth confirming on a throwaway pair of test objects before trusting it in a real pipeline.
What each strategy probably does
Based on the three option names alone: override (the default) reads as "later wins" - where both inputs define the same key, json_input_2's value replaces json_input_1's. preserve reads as the opposite - json_input_1's existing keys are kept, and json_input_2 only fills in whatever json_input_1 doesn't already have. concat is the genuinely ambiguous one: it could mean concatenating matching array values together rather than replacing them, or something closer to literal string concatenation of the two JSON blobs - the schema doesn't say, and this is exactly the kind of behavior you want to verify with a small test pair before relying on it for anything that matters.
Inputs and outputs
Two required inputs, json_input_1 and json_input_2, both multiline STRING fields expected to hold valid JSON text. One more required input, merge_strategy (enum: override/preserve/concat, default override). One output: merged_json, a STRING.
Where this fits
Useful anywhere you're assembling structured metadata from two separate sources before it reaches a node that consumes JSON - a base configuration merged with per-run overrides, or combining a caption model's structured output (this pack's KY_OpenAICaptionImage supports a json_object response format) with additional fields you're adding yourself. Pair the output with this pack's KY_Eval_Python if you need logic beyond a simple two-way merge - parsing, filtering, or reshaping the resulting JSON with real code.
Installing it
ComfyUI Manager: search ComfyUI-KYNode, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/yorkane/ComfyUI-KYNode
Restart ComfyUI. No external dependencies - JSON parsing is standard-library territory.
Common issues
Both inputs need to actually be valid, parseable JSON - this is a STRING-in/STRING-out node with no schema validation shown anywhere, so a malformed JSON string on either side is the most likely first failure, and expect a parse error rather than a graceful partial merge.
Given the lack of a documented description, don't assume concat's behavior without testing it on your own data first - feed it two small, simple JSON objects with a deliberately overlapping key and a deliberately overlapping array, and look at exactly what comes out before you build a real pipeline around a specific expectation of what "concat" means here.
If the merged result doesn't parse cleanly downstream, check that whatever's consuming merged_json is actually expecting a JSON string to parse itself, rather than a native object - this node's output type is STRING, so a downstream node expecting a typed JSON socket may need an explicit parse step in between.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| json_input_1 | STRING | — | |
| json_input_2 | STRING | — | |
| merge_strategy | COMBO | override | 3 options: override, preserve, concat |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| merged_json | STRING | — |