ComfyUI Node

extend

Extend — the append you meant when you had two lists

By StableLlama·Created about a year ago·Updated 4 days ago· 48
extend
  • 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, or any.

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

  • extend for merging lists, append for 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 LIST first.
  • Output is a LIST (single Python list variable), not a native data list - the pack's usual distinction.
CategoryBasic/LIST

Inputs (2)

NameTypeDefaultDescription
list1LIST
list2LIST

Outputs (1)

NameTypeDescription
LISTLIST