ComfyUI Node

Loop Texts

The node that turns one queue into a hundred different images

By luku756·Created about a month ago·Updated about a month ago· 0
Loop Texts
    • STRING
    input_size2
    general_title
    general_prompt

    Loop Texts is the reason the StringKit pack exists. It collects a handful of string inputs into one list, and because that list output is flagged as a list, ComfyUI runs everything downstream once per element. Wire a batch of prompts into it, run the queue, and you get one image per prompt - no Python, no API, no scripting. This is where ComfyUI stops being a pipeline and starts being a program with a queue button.

    How the looping actually works

    Each connected input acts as one "column," and the node walks them row by row. Three columns of lengths 4, 6, and 2 produce the order 1-1, 2-1, 3-1 / 1-2, 2-2, 3-2 / and so on, skipping columns that have run out. Total outputs is the sum of the column lengths (12 there), not the max times the count (18). A single scalar connected anywhere just becomes a length-1 column.

    That row-major order is deliberate: it's the only way to keep the old scalar behavior where text_1, text_2, text_3 … came out in exactly that order. You can even feed another Loop Texts' output into a slot - a loop inside a loop - and the general prefixes accumulate, outer loop first.

    The inputs you'll actually touch

    • input_size - 1 to 50, how many text_* slots (and their toggles) exist.
    • general_title - prepended to every element's title with a single space, because titles end up as folder names. Leave empty and nothing is added.
    • general_prompt - prepended to every element's prompt with , (comma-space), the prompt convention. Ends in a comma already? You get a space, not a double comma. This is your "masterpiece, best quality" slot - type it once, batch a whole group.
    • text_1 … text_N - the things being looped. Each can be a scalar, a prompt with a hidden title (from Titled Text), or another list.
    • enable_1 … enable_N - the on/off toggles. Flip one off and that slot is treated as unconnected without unplugging the wire: the socket goes grey and reads text_N (off). Perfect for A/B-ing a slot in and out of a batch. They're folded away by default (there's a ▶ on/off button to expand them), and the folded state is saved in the workflow.

    The one thing to keep straight

    The elements' titles only survive inside StringKit. The loop itself preserves them - it's what feeds Unpack Text and Seed List further down - but if you route the loop output through another pack's string node first, the title is gone and Seed List will happily seed off the prompt text instead. Same silent-dissolve gotcha as everywhere else in this pack.

    Install

    ComfyUI-StringKit is MIT, pure Python plus a bit of frontend JS for the dynamic sockets - no models, no dependencies, no API keys. Install via ComfyUI Manager (search ComfyUI-StringKit) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/luku756/ComfyUI-StringKit
    

    Then a full ComfyUI restart - the socket/toggle UI is JS and won't load on a hot reload. All nodes live under the StringKit category.

    A typical batch rig: several Titled Text nodes feeding one Loop Texts, then Unpack Text → CLIP encode → sampler, with Seed List riding along so your fifty variants don't all share one seed. That's a real workflow in four nodes, and it's the highest-leverage thing this pack does.

    CategoryStringKit

    Inputs (3)

    NameTypeDefaultDescription
    input_sizeINT21–50
    general_titleSTRING
    general_promptSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING