Nodes/ymc-node-suite-comfyui/random text in list
ComfyUI Node

random text in list

Roll the dice on your prompt list, reproducibly

By YMC-GitHub·Created 3 years ago·Updated about a year ago· 20
random text in list
    • text
    • seed
    text
    seed0
    char|

    Sometimes you don't want to iterate a list in order - you want to roll it. Random text in list takes a pipe-separated string and picks one item at random, seeded, so you can reproduce the same pick later or let it surprise you each run. It's the chaotic cousin of get text in list (loop), and it earns its place in any workflow where you want random variation in your prompt without touching the sampler.

    The loop node walks the list deterministically; this one hops. Wire it into a prompt, hit queue, and you get a different subject/color/style token each run. Because the pick is seed-driven (random.choice after random.seed(seed)), the same seed always yields the same item - so when a run lands on something great, you can pin the seed and reproduce it exactly. That reproducibility is what separates this from a pure random node.

    How it works

    The mechanism is two lines of Python: split text on char (default |), seed Python's RNG with your seed, then random.choice the list. The IS_CHANGED flag is set to NaN, which forces ComfyUI to re-execute the node on every run rather than caching - essential, or the "random" pick would freeze at the first one.

    Inputs and outputs

    • text - your pipe-delimited list, e.g. red|blue|green|yellow
    • seed - the RNG seed, 0 to 2^64; same seed, same pick
    • char - the separator, default |
    • Outputs: text (the chosen item) and seed (echoed back)

    Wire text into your prompt builder; keep seed if you want to log what was picked for later reproduction.

    Installing it

    # ComfyUI Manager: search "ymc suite" and install ymc-node-suite-comfyui
    # or:
    cd ComfyUI/custom_nodes
    git clone https://github.com/YMC-GitHub/ymc-node-suite-comfyui
    

    Restart after installing. Dependencies are four small pure-Python PyPI helpers that self-install; no models, no GPU footprint.

    Gotchas

    • The separator is a literal split, so if your list items contain | you're in trouble - pick a char that doesn't appear in your data.
    • It picks from the whole list every time; there's no "no repeats until exhausted" logic like the loop node's wraparound. With small lists you'll see repeats, which is correct random behavior but easy to mistake for a bug.
    • random.choice on an empty list (empty text) errors - keep at least one item in the field.
    • If you also run WAS Node Suite, Manager may flag shared node names between the two packs; disable one if you see save-node conflicts.
    Categoryymc suite/text/plain

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    seedINT00–18446744073709550000
    charSTRING|

    Outputs (2)

    NameTypeDescription
    textSTRING
    seedINT