Nodes/Nilor Nodes by Nilor Corp/๐Ÿ‘บ Random String
ComfyUI Node

๐Ÿ‘บ Random String

A seeded random picker for A/B prompt testing

By nilor-corpยทCreated 2 years agoยทUpdated 5 months agoยท 6
๐Ÿ‘บ Random String
    • chosen_string
    โ—„multiline_textoption1, option2, option3โ–บ
    โ—„max_options3โ–บ
    โ—„delimiter,โ–บ
    โ—„seed0โ–บ

    Want a node that picks a random item from a list every run? ComfyUI's core has a "random prompt" trick via wildcards, but it's awkward to seed and fiddly to keep deterministic. Nilor Random String is the simpler version: you type a list of options into a multiline text box, it picks one at random, and hands it back as a string you can feed into your prompt or filename. It's a small thing, but it's the difference between "let me try 20 prompt variants" and "let me build a graph that tries them for me".

    How it works

    The inputs are refreshingly few:

    • multiline_text - your options, separated by delimiter (default ,). It's a multiline widget, so you can also write each option on its own line and set the delimiter to \n (the node recognizes the literal two-character string \n and treats it as a newline).
    • max_options - if your text has more options than this (default 3), it uses only the first N. This is a cap, not a count.
    • seed - feeds Python's random.seed(), so the same seed + same list = same pick. Default 0.

    It strips whitespace, drops empty entries, errors if you somehow end up with no options, then returns chosen_string. That's the entire behavior, and it's exactly right for the job.

    The seed catch that trips people

    Because the node calls random.seed(seed) and then random.choice, the output is deterministic given the same seed. Set seed 0, run once, get "option2"; run again with seed 0, you get "option2" again. If you want a fresh pick each run, you need to vary the seed - wire in a seed-generator, or connect the ๐Ÿ‘บ User Input (Seed) node from this same pack. The other gotcha: changing the list content (even order) changes what a given seed returns, so don't expect seeds to stay "stable" across edits.

    Also note this is not cryptographic randomness and not a true random-number stream - it's the seeded PRNG, which is what you want for reproducibility. The moment your variant testing needs to be reproducible per-seed, this beats a wildcard node that hides its state.

    Where it fits

    Classic use: a list of style suffixes or negative-prompt tweaks, feeding into a text-concatenation node that builds the full prompt, with the seed as your experiment index. Run the workflow with a seed sweep and each image becomes a different variant of the same base - great for A/B testing without editing widgets between runs. Pair it with ๐Ÿ‘บ List of Ints or any loop driver if you want the seed to walk through options in a controlled order instead of randomly.

    Install

    ComfyUI Manager (search "Nilor Nodes") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/nilor-corp/nilor-nodes
    cd nilor-nodes && pip install -r requirements.txt
    

    Restart ComfyUI; find it under Nilor Nodes ๐Ÿ‘บ โ†’ Utilities. No dependencies beyond Python's stdlib random, so nothing extra to install.

    Bottom line

    It's a two-minute utility dressed as a node, but that's the point - it saves you two minutes every single time you'd otherwise hand-roll it. If you only take one thing from this article: the seed is doing real work here, so treat it like a dial, not a formality. That's the difference between "random is random" and "random I can reproduce".

    CategoryNilor Nodes ๐Ÿ‘บ/Utilities

    Inputs (4)

    NameTypeDefaultDescription
    multiline_textSTRINGoption1, option2, option3โ€”
    max_optionsINT3โ€”
    delimiterSTRING,โ€”
    seedINT00โ€“18446744073709550000โ€”

    Outputs (1)

    NameTypeDescription
    chosen_stringSTRINGโ€”