extend
Extend — the append you meant when you had two lists
- list1
- list2
- LIST
extend is the node for "I have two lists and I want one list." It takes list1 and list2, and returns a new LIST with every element of the first followed by every element of the second. On the surface it's the boring merge operation; in practice it's the difference between a workflow that concatenates cleanly and one where you're forever fighting nested lists.
How it works
It's list.extend() with the ComfyUI-friendly copy-first pattern:
result = list1.copy()
result.extend(list2)
return (result,)
The input lists are untouched - you get a brand-new merged list, so you can keep using list1 or list2 elsewhere in the graph without the merge side-effecting them. That non-mutating behavior is consistent across this whole pack, and it's one of the reasons these nodes compose well.
The key contrast with append: extend flattens the second list's contents into the result, while append would add the second list as a single nested element. So extend(["a"], ["b", "c"]) gives ["a", "b", "c"], whereas append on the same inputs gives ["a", ["b", "c"]]. If you've ever looked at a result with surprise brackets in it, you found the wrong node. Output is a single LIST.
Where you'd use it
- Joining collections. Merge two seed lists, two prompt lists, or a default list with a per-run add-on list.
- Building a batch incrementally. Assemble a growing list by extending with the results of each step.
- Preparing data for the operations nodes - a single merged list feeds cleanly into
sort,max,min,all, orany.
Installing
It's in the "Basic data handling" pack by StableLlama. ComfyUI Manager: search "Basic data handling", install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI. Zero dependencies, no models - pure Python wrappers, about as clean an install as custom nodes get.
Gotchas worth knowing
extendfor merging lists,appendfor adding a single element. Pick by what you're adding, not by what feels similar.- Both inputs must be LISTs; there's no coercion here. If one side is a plain value, wrap it in a
create LISTfirst. - Output is a LIST (single Python list variable), not a native data list - the pack's usual distinction.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| list1 | LIST | — | |
| list2 | LIST | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LIST | LIST | — |