Nodes/Sage Utils/Text Random Line
ComfyUI Node

Text Random Line

A random pick from a list, seeded so you can reproduce it

By arcum42·Created 2 years ago·Updated 28 days ago· 33
Text Random Line
    • random_line
    text
    seed0

    You want variety without chaos: paste a list of options, one per line, and have the node hand back a random one. That's Text Random Line. It's the node you use for random prompt variations, random subjects, random anything - except it has a seed input, which turns "random" into "random, but reproducible when you need it to be."

    How it works

    Two inputs: text (multiline - each line is a candidate) and seed (an int). The node splits the text into non-empty lines, strips whitespace, and picks one using Python's random module seeded with your value. Output is the single chosen line as random_line. Blank lines are skipped, so you can format your list loosely without counting empty lines in the odds.

    The seed is the whole trick. Same text, same seed → same line, every time. That's what makes this usable in a real workflow: you can build a batch that runs N variations, lock a seed when you find a combo you like, and reproduce it exactly - or wire the seed to a counter to get a controlled sequence of different picks. Change the seed and you shuffle the deck.

    Where it fits

    The obvious use is prompt variety - a list of subjects, styles, or lighting descriptions, one randomly chosen per run. It's also handy for any small randomized choice in a workflow: random location names, random prefixes, random captions. If you find yourself hand-editing a Set Text node between runs to get variation, this is the automated version.

    Installing it

    Part of the Sage Utils pack - ComfyUI Manager (search Sage Utils) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/arcum42/ComfyUI_SageUtils
    cd ComfyUI_SageUtils
    pip install -r requirements.txt
    

    Restart ComfyUI. Only pip dependency is dynamicprompts; no model downloads.

    The catch

    If your text is a single line, there's nothing random going on - you'll get that line back regardless of seed, and it'll look like the node is "broken." It isn't; it needs options to choose from. And remember the seed controls only this node's pick, not your sampler seed - if you want the whole workflow deterministic, the sampler seed and this seed need to be coordinated, not just this one. For picking a specific line rather than a random one, the pack's Text Select Line node is the sibling you want.

    CategorySage Utils/text/line

    Inputs (2)

    NameTypeDefaultDescription
    textSTRINGText to take a random line from.
    seedINT0Random seed used to choose the line.

    Outputs (1)

    NameTypeDescription
    random_lineSTRINGOutput value for random_line.