Nodes/ComfyUI-lhyNodes/CSV RandomPicker
ComfyUI Node

CSV RandomPicker

Roll a random prompt fragment from a CSV, seeded so you can reproduce it

By lihaoyun6·Created 12 months ago·Updated 13 days ago· 20
CSV RandomPicker
    • STRING
    csv_stringapple,banana,cat,dog
    count1
    separator,
    seed0

    Wildcards - prompt fragments that randomize per run - are a bread-and-butter ComfyUI trick for batch variation. Most people implement them with a wildcard pack that reads files from disk. CSVRandomPicker is the no-files version: paste a comma-separated list right into the node, pick a seed, and get a random selection out as a string you can splice into a prompt.

    The pitch is exactly as low-maintenance as it sounds. No folder structure, no .txt files to manage, no wildcard syntax to remember - the CSV lives in the widget, travels with the workflow when you save it, and the seed makes every pick reproducible. A thread on r/comfyui that surfaces this pack praises its Queue Handler; the string utilities are the quieter half of the same "just make the graph do the work" philosophy.

    How it works

    The node splits csv_string on your separator (default comma), trims each item, then samples with random.Random(seed). Two details matter. First, it uses sample, which means no duplicates - you'll never get the same item twice in one pick, which is what you want for "choose 2 poses out of 5." Second, the RNG is seeded, so the same seed + same list + same count always yields the same selection. That's the reproducibility you need to share a "rolled" prompt with a specific image.

    Output is the selected items joined back with the same separator - a string, ready to drop into a prompt text box (or into a template via a format node).

    Inputs and outputs

    • csv_string (STRING, multiline) - the pool. Default apple,banana,cat,dog.
    • count (INT, 1–1000, default 1) - how many to pick. Capped at the list length.
    • separator (STRING, default ,) - what splits the list.
    • seed (INT, default 0) - the dice. Change it, get a different roll.

    One output: STRING, the sampled items joined by the separator.

    Installing it

    Part of ComfyUI-lhyNodes:

    • ComfyUI Manager → search lhyNodes → Install, restart.
    • Or manually:
    cd ComfyUI/custom_nodes
    git clone https://github.com/lihaoyun6/ComfyUI-lhyNodes.git
    python -m pip install -r ComfyUI-lhyNodes/requirements.txt
    

    Restart ComfyUI.

    Where people get burned

    The separator is literal - if you use , (comma-space) as your separator, items must be split with , and the output is joined with , too; mix up comma-only on input with comma-space output and your items carry leading spaces. Also, an empty line or trailing comma creates empty items, but the node strips empties before sampling so it's mostly harmless. The real limitation is scale: the list is a widget, so enormous pools get unwieldy to edit - for a 500-entry wildcard list you'd want a file-based wildcard pack instead. For "rotate through a dozen prompts on a batch," this is the one.

    CategorylhyNodes/String

    Inputs (4)

    NameTypeDefaultDescription
    csv_stringSTRINGapple,banana,cat,dog
    countINT11–1000
    separatorSTRING,
    seedINT00–1125899906842624

    Outputs (1)

    NameTypeDescription
    STRINGSTRING