ComfyUI Node

extend

Merge two data lists into one, the non-nesting way

By StableLlama·Created about a year ago·Updated 4 days ago· 48
extend
  • list_a
  • list_b
  • list

Two lists walk into a workflow. One's the output of a filter, the other's the output of a previous batch. You want them as one list. extend is the node that merges them - and unlike append, it merges them flat, so you get [a, b, c, d] and not [a, [b, c, d]].

It's part of Basic data handling, StableLlama's zero-dependency utility pack, and it's the Data List family's join operation.

How it works

Python's list.extend(), expressed as pure concatenation: list_a + list_b. Both inputs are marked optional and accept ANY, so you can merge two lists of the same type or combine anything the pack can carry. The output is a new data list holding every element of list_a followed by every element of list_b.

The key difference from append is worth hammering: append adds one item as a single element; extend splices a whole second list in as individual elements. If you accidentally use the wrong one, you either lose items or end up with a nested list that downstream nodes won't iterate the way you expect.

The inputs and output

  • list_a (*, optional) - the first list.
  • list_b (*, optional) - the list to append onto the first.
  • list (output) - the combined data list.

A realistic use

Recombining after a split is the classic case. If a filter split your batch into kept and dropped, extend can re-join them when a later stage should process everything again. Or accumulate results across two branches: run two sampler paths and merge their image lists into one batch for a single save step.

Installing it

ComfyUI Manager → search "Basic data handling", or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart. No dependencies, no models.

Common issues

  • "I got a nested list back." That's append's behavior, not extend's - check which node you actually wired. Extend concatenates flat.
  • "One input was empty and nothing came through." If an input is unconnected, it's treated as an empty list, so the output is just the other side. Wire both if you expect both.
  • "The order looks wrong." It's strictly list_a then list_b. If your merged order is off, swap the inputs.
CategoryBasic/Data List

Inputs (2)

NameTypeDefaultDescription
list_aopt*
list_bopt*

Outputs (1)

NameTypeDescription
list*