Nodes/ComfyUI-mnemic-nodes/🎲 Random String
ComfyUI Node

🎲 Random String

Pick One Line at Random From a List You Type In

By MNeMoNiCuZΒ·Created 3 years agoΒ·Updated a day agoΒ· 105
🎲 Random String
    • random_choice
    β—„input_listoption1 option2 option3β–Ί
    β—„seed-1β–Ί

    🎲 Random String does one thing: it takes a box of newline-separated options and returns one of them. Type golden hour / overcast / neon dusk and each run picks a lighting mood. It's the smallest possible version of the wildcard idea, and sometimes that's all you want - no files, no syntax, no separate wildcard folder to manage.

    It's also the node that made the randomise-your-prompt habit click for people. Everything else in a workflow gets variety - seed, steps, sampler - but the prompt text tends to get typed once and frozen, which is why so many batches look like the same picture twenty times.

    How it works

    input_list is split on newlines, each line is stripped, and blank lines are dropped. Then one line is picked. If nothing survives the strip - an empty box, or a box of blank lines - you get an empty string back rather than a crash, which is polite and also quietly ruins a run if you didn't notice the box is empty.

    seed is optional, default -1. Set a real value and the pick is deterministic (a locally seeded RNG), which is how you get a reproducible variant: seed 7 always picks line 3, so you can compare two workflows on identical text. Leave it -1 and it draws from the unseeded RNG, i.e. different each execution - bearing in mind ComfyUI's cache, which skips nodes whose inputs didn't change. The pack's Random Seed node forces a re-run via a timestamp fingerprint; this one doesn't, so if the pick looks frozen that's why.

    One thing this node does not do: substitute into a sentence. There's no {a|b|c} syntax here - the output is exactly one whole line. If you want text embedded mid-prompt, either build the line with String Concat, or move up to the pack's Wildcard Processor, which handles inline choices, weighted picks, {2$$a|b|c} multi-select, variables, file wildcards and <lora:...> tags in one go.

    Inputs and outputs

    Required: input_list, a multiline string, prefilled with option1 / option2 / option3 so you can see the format. Optional: seed. One output, random_choice, STRING - wire it into a CLIP Text Encode, or into String Concat if it's a fragment of a larger prompt.

    Install

    ComfyUI Manager β†’ search "ComfyUI-mnemic-nodes" β†’ install β†’ restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MNeMoNiCuZ/ComfyUI-mnemic-nodes
    

    No downloads, no keys. The pack's requirements.txt (transformers, opencv-python, tiktoken, piexif, groq and friends) belongs to its other nodes; this one is plain Python.

    Common issues

    Blank results. Every line was empty or whitespace. Check the box.

    The pick never changes. Cache or a fixed seed - set seed to -1 and change something upstream, or increment the seed yourself.

    You wanted one option inside a longer prompt. Wrong node. Use the Wildcard Processor's {a|b|c} inline syntax, which is built for exactly that.

    Trailing spaces behaving oddly. The node .strip()s each line, so indentation and trailing whitespace are gone by design. Don't rely on them.

    Category⚑ MNeMiC Nodes

    Inputs (2)

    NameTypeDefaultDescription
    input_listSTRINGoption1 option2 option3Newline-separated list of strings to randomly choose from. Each line is one option.
    seedoptINT-1-1–18446744073709550000Seed for random number generator. Use -1 for random seed (different each time), or set a specific value for reproducibility.

    Outputs (1)

    NameTypeDescription
    random_choiceSTRINGOne line picked at random from the list above. Empty if the list has no usable lines.