ZML_批次转列表
Unpack a batch into a list so you can work on each image alone
- 图像批次
- 图像列表
- 文本列表
A sampler hands you a batch of images in one tensor, but the node you want next operates on single images. ComfyUI's modern engine can iterate over lists natively, so the fix is to turn that batch into a list - and that's literally the whole job of ZML_Batch_To_List (ZML_批次转列表). It splits an image batch into a list of individual images, and it'll split text the same way using a separator you choose. One node, two unpackings, both outputs list-typed so downstream nodes know they're getting a sequence.
What it is
A data-shape converter from ComfyUI-ZML-Image, born out of the author discovering that ComfyUI can now handle multiple list items like n8n workflows can (that's his own README note). The inputs:
- 分隔符 (STRING, default
,\n) - used for the text split. - 图像批次 (IMAGE, optional) - a batched tensor, e.g. straight off a KSampler with batch size 4.
- 合并文本 (STRING, optional) - a single blob of text you want split into a list.
Outputs:
- 图像列表 (IMAGE,
is_list: true) - the batch unpacked: one image per list item. - 文本列表 (STRING,
is_list: true) - the merged text split on your separator.
Both outputs are explicitly list-typed, which is the whole point: the executor sees OUTPUT_IS_LIST = (True, True) and knows downstream consumers should be invoked once per item. You can use just one side or both at once.
How it works
Mechanically it's boring in the good way: the batch tensor is split on the batch axis into individual tensors, and the merged text is split on your separator string, with empty entries dropped so trailing separators don't produce phantom list items. The list typing is what makes it useful - in current ComfyUI you can chain a list output into another node that accepts lists and it'll run once per item, which is how you do "take this batch, watermark each image, save each one" without a loop of your own.
Install and gotchas
Standard pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
or ComfyUI Manager → ComfyUI-ZML-Image, restart. No extra dependencies.
The gotcha is the separator, and it's a classic escape-sequence trap. The default is shown as ,\n, and you have to get the literal characters right: if the field stores a backslash-n as text instead of a real newline, your text won't split where you expect. If your merged text is comma-separated prompt tags, set the separator to just ,. If you leave 合并文本 unwired, the text output is just an empty list - harmless. And remember the list semantics: not every downstream node accepts list inputs, so a node that errors after this one is usually complaining about the list, not about you. Chinese-first UI, English patch at github.com/zml-w/ZZZ_ZML_English_Patch. Small utility node, one-person pack, no English community - but it does exactly one thing, so there's not much to get wrong beyond the separator.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| 分隔符 | STRING | ,\n | — |
| 图像批次opt | IMAGE | — | |
| 合并文本opt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 图像列表 | IMAGE | — |
| 文本列表 | STRING | — |