Nodes/Comfyui-General-API-Node/Text Iterator (FeiMao-326)
ComfyUI Node

Text Iterator (FeiMao-326)

Split text into a list and run the whole downstream graph once per item

By FeiMao-326·Created 12 months ago·Updated 5 months ago· 0
Text Iterator (FeiMao-326)
    • text
    text
    delimiter,

    Batch generation is where ComfyUI stops being a toy. You have a text file full of prompts, or an LLM just handed you ten of them, and you want one image per line - without building ten identical branches. That's the job of this node: it splits text on a delimiter and outputs it as a list, which tells ComfyUI to run everything downstream once for each item.

    How it works

    Feed it a multiline text and a delimiter (default ,), and it does a straightforward split, trimming whitespace off every item. The key difference from a normal split node is that its output is marked as a list (OUTPUT_IS_LIST), and ComfyUI's executor treats list outputs as a batch trigger: whatever you wire into next runs repeatedly, once per element.

    So you connect a text block like cyberpunk alley, rain at night, neon market into it, run the graph, and you get three generations. It's the same pattern the batch-iteration crowd uses everywhere - think of it as a lightweight for loop around your sampler.

    A couple of implementation details that matter:

    • If your delimiter is \n typed literally, it's converted to an actual newline, so multi-line prompt files work naturally.
    • Items get stripped, so stray spaces around your commas won't produce " ghost prompts" with leading whitespace.
    • If the delimiter is empty, the whole text comes back as a single-item list.

    What to watch for

    The honest caveat with list-driven iteration in ComfyUI: it reuses the graph's state, and nodes that hold state between runs can behave oddly when their input is a list. The node itself is trivial - there's no logic to go wrong - but if you're driving a KSampler this way, keep an eye on whether your seed node is upstream of the iterator or outside the loop. Seeds that live inside the iterated branch get recomputed per item; seeds outside it don't, which is exactly what you want for controlled variations.

    Also, note the distinction between this and the pack's Text Split By Delimiter node. Split produces a LIST output meant for Get List Element - you grab one element by index. This iterator produces a string list meant to fan out into the graph. Same split logic, opposite philosophy. If you find yourself wanting both "split once, index it later" and "split, then branch per item," you'll want both nodes.

    Inputs and outputs

    • text (STRING, multiline) - the text to split.
    • delimiter (STRING) - what to split on. Default is ,.
    • text (STRING, list) - the resulting items.

    Two inputs, one output. That's the whole thing.

    Installing

    This is one of the sixteen nodes in the FeiMao-326 pack, so you install the pack once:

    cd ComfyUI/custom_nodes
    git clone https://github.com/FeiMao-326/Comfyui-General-API-Node.git
    cd Comfyui-General-API-Node
    pip install -r requirements.txt
    

    Restart ComfyUI. Dependencies are light (openai, numpy, Pillow, requests), and there are no model files to fetch. ComfyUI Manager users can search "Comfyui-General-API-Node" instead of cloning.

    CategoryFeiMao-326

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    delimiterSTRING,

    Outputs (1)

    NameTypeDescription
    textSTRING