Nodes/EBU PromptHelper/EBU PromptHelper List Sampler
ComfyUI Node

EBU PromptHelper List Sampler

Shuffle a list, grab N items, renumber them — your batch's variety engine

By burnsbert·Created 2 years ago·Updated 24 days ago· 2
EBU PromptHelper List Sampler
    • STRING
    list
    seed0
    number_of_elements10
    number_sampled_listfalse

    List Sampler is the pack's batch-variety workhorse: it takes a newline-separated list, shuffles it, and hands back a random subset of however many items you ask for - renumbered if you want. If your workflow feeds a big list of "quality traits" or "scene details" into a prompt, this is the node that makes every image in a batch feel different without you curating combinations by hand. It's the natural partner to the pack's Randomize node: Randomize swaps one token for one option, List Sampler hands you a whole shuffled handful.

    How it works

    The mechanism is worth knowing because of one specific behavior: it cleans your list for you. Each line is processed by stripping a leading number-and-dot (so 12. sparkles becomes sparkles) and trimming whitespace, then blank lines are dropped entirely. The cleaned lines get random.shuffle()d with your seed, the first number_of_elements are kept, and if number_sampled_list is on they're renumbered 1, 2, 3, …. That number-stripping is surprisingly handy if you copy lists from somewhere formatted, but it also means a literal item that starts with 123. gets mangled - worth remembering if your list is, say, hex codes or sentence fragments that could begin with digits.

    The inputs and output

    • list - your multiline list. The only truly required field.
    • seed - 0 for non-deterministic; a fixed seed reproduces the same subset.
    • number_of_elements - how many to sample, default 10, min 1, max 1000. If the list is shorter, you get everything it had.
    • number_sampled_list - when on, the output is numbered (1. item), which pairs perfectly with tag-style prompt blocks where order implies emphasis.

    Single output: the sampled items joined by newlines. If you want them in a comma-separated single line instead, run the output through the pack's Replace node and swap \n for , - the example workflow literally does this.

    Where it fits

    The pack's Flux example uses it to grab three random "quality" descriptors for each generation, and it's a fine general pattern: keep a long list of traits you like, sample a handful per run, drop them into your prompt block. Because it shuffles and samples rather than consumes, repeats are allowed - the same trait can show up in consecutive batches. That's the difference from Consume List Item, which explicitly removes what it drew. Use List Sampler when repetition is fine and you want quick variety; use Consume when you need no-repeats coverage.

    Install

    Part of EBU PromptHelper. ComfyUI Manager: search "EBU PromptHelper", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/burnsbert/ComfyUI-EBU-PromptHelper
    

    Restart ComfyUI. No models, no extra pip dependencies - standard library only.

    Troubleshooting

    If the output has fewer items than you asked for, the list was shorter than number_of_elements - that's by design, it returns what exists. If a line comes back missing its first few characters, that's the number-stripper eating something that looked like 7. text. And if you set a fixed seed and nothing changes between runs, that's the feature working: same seed, same shuffle. Set the seed to 0 (or leave it random) when you want every run to differ.

    CategoryPrompts

    Inputs (4)

    NameTypeDefaultDescription
    listSTRING
    seedINT00–18446744073709550000
    number_of_elementsoptINT101–1000
    number_sampled_listoptBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    STRINGSTRING