Nodes/comfyui-text-randomizer/Get one text or another at random
ComfyUI Node

Get one text or another at random

The two-way text chooser

By nosiu·Created about a year ago·Updated 3 months ago· 3
Get one text or another at random
    • text
    text1
    text2
    seed0

    The simplest node in the pack, and the one that's easy to misuse

    "Get one text or another at random" is a coin flip for strings: feed it two pieces of text, and each run it hands back one, 50/50. It sounds almost too trivial to install a node for - and honestly, if you only ever want to randomize one slot in a prompt, the Text randomizer does more in less space. Where this node earns its place is when the two options are built out of other nodes. Because both inputs are marked as forced inputs, they're meant to receive text over wires, not from your typing.

    That's exactly what the pack's own workflow2.json shows: two RandomizeText nodes each generate a full prompt, and this node picks which one of the two composite prompts actually goes to the encoder. The result is that you get the same variety as one giant randomizer, but each half is a readable, reusable block you can tweak or swap without editing a wall of [a|b|c|d|e].

    How it works

    Nothing clever under the hood - and that's fine:

    random.seed(seed)
    text = random.choice([text1, text2])
    

    It calls random.seed(seed) before the choice, so the same seed always lands on the same option. That's the node's superpower and its trap. Reproducibility is great: for an honest A/B test of two prompt variants, fix the seed, run, and know both sides saw identical conditions. But it means the default seed of 0 is deterministic - run it ten times with the seed left alone and you'll see the same option ten times. Newbies who install this expecting chaos get a coin that always lands heads until they actually change the seed. Feed it a varying seed and it's a true 50/50.

    Inputs and outputs

    • text1 (multiline, forced input) - first candidate. Wire it from a RandomizeText, a ConcatText, or anything outputting a STRING.
    • text2 (multiline, forced input) - second candidate.
    • seed (INT, 0 to 2^64-1, default 0) - decides the side. Deterministic for a fixed value.

    Output is a single text (STRING) that flows into your text encoder like any other prompt string.

    Because both inputs are forced, you typically can't just type into them - the node expects connections. If you want one side to be hand-typed boilerplate, right-click the widget and convert it, or feed it through a plain string node.

    Installing it

    Same dependency-free pack as the rest:

    cd ComfyUI/custom_nodes
    git clone https://github.com/nosiu/comfyui-text-randomizer
    

    Restart ComfyUI. Or in ComfyUI Manager, search for comfyui-text-randomizer. No requirements.txt, no models, no pip step. If you already installed the pack for the Text randomizer, this node is already in your node list - no extra work.

    Where it's actually useful

    • A/B testing two full prompts at a fixed seed - the honest way to compare, since one variable changes per run.
    • Two styles, one workflow - e.g. switch a subject RandomizeText output against a "no subject" empty string via [x|], so sometimes the composition is empty of the subject.
    • Random between two composite prompts built from ConcatText blocks, exactly like the shipped example workflow.

    Troubleshooting

    • It always picks the same option - seed is fixed (probably 0). Change the seed to get the other side, or wire it to something varying.
    • Can't type into the inputs - they're forced inputs by design; connect nodes, or convert the widget via right-click.
    • Expecting it to randomize inside a prompt - it won't; it picks whole strings. That's the Text randomizer's job. Use this only for choosing between pre-built blocks.

    One honest caveat: this is a niche node from a small pack with essentially no community footprint - if you outgrow it, rgthree's Power Puter or similar can branch on computed values, but for a plain 50/50 this is the most readable option there is.

    Categoryrandomizer

    Inputs (3)

    NameTypeDefaultDescription
    text1STRING
    text2STRING
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    textSTRING