Nodes/ComfyUI-Prompt_Library/Five Random Lines
ComfyUI Node

Five Random Lines

Building Varied Prompts from Five Pools

By hexxacubic·Created about a year ago·Updated 2 months ago· 7
Five Random Lines
    • double_prompt
    global_prompt
    text_1
    text_2
    text_3
    text_4
    text_5
    prepend_modefalse
    seed0

    FiveRandomLines is the batch-variation workhorse of this pack. You feed it five separate pools of prompt lines - a pool of styles, a pool of subjects, a pool of lighting, whatever - plus one static "global" prompt, and it rolls one line out of each pool and stitches them into a single prompt. Run it five times, get five genuinely different compositions instead of five re-rolls of the same sentence.

    The mental model is simple: one field per slot, one line picked per field. Keep your pools thematically separate and the combinations stay coherent. It's the kind of node you set up once for a character-expression or concept-exploration batch and then forget about.

    How it works

    Each of the five text fields is split on newlines; one line is selected from each. The selection is seed-driven - the node reseeds Python's random generator with seed + field_index per field, so all five picks are independent but reproducible from a single seed. The global_prompt field is not random: it's your constant base, the part that must be there every time.

    Every selected line can itself carry the pack's --- convention to split positive/negative. The positives from all picked lines are merged into one positive side, the negatives into one negative side, and the whole thing is emitted as a double-prompt string. prepend_mode decides whether the global prompt leads (true) or trails (false) the random parts.

    The combine step is thoughtful: it inserts a comma between parts only when one isn't already there, so you don't end up with masterpiece,, detailed.

    The inputs that matter

    • global_prompt - your static base, e.g. masterpiece, best quality --- blurry, low quality.
    • text_1text_5 - five pools, one line per variant. Any field you leave blank is simply skipped.
    • prepend_mode - put the global prompt first (default) or last.
    • seed - controls which line each pool picks. Fix it to reproduce a batch; change it to explore.

    Outputs

    • double_prompt - a STRING in the positive\n---\nnegative format. Wire it into Double_Prompt_Encode to get conditioning, or into a text viewer to eyeball it.

    How to install it

    Install the pack via ComfyUI Manager (search ComfyUI-Prompt_Library) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/hexxacubic/ComfyUI-Prompt_Library
    

    Restart ComfyUI. No pip step, no model downloads - it's pure standard library. It shows up under the hexxacubic category.

    Where people get burned

    Two things trip people up. First, empty fields are silently skipped - if you expect five lines in the output and you're getting four, one of your text boxes is blank or full of blank lines. Second, the seed is doing all the reproducibility work: if you leave it moving or use it to drive other nodes, the troubleshooting rule from the community applies hard here - fix the seed while you're debugging, then unfreeze it when you actually want variation. The node even resets the random state when it's done so it doesn't contaminate other nodes, which is the kind of hygiene you learn to appreciate.

    One trap worth naming: this node does not randomize the global prompt, ever. People sometimes assume all six fields roll. If you want the constant-to-variable balance shifted, that's what prepend_mode is for - flip it and the random parts lead, which changes how the model weights the sentence. Earlier tokens get more attention on SDXL-lineage models, so where you put the "always include" text genuinely matters.

    Categoryhexxacubic

    Inputs (8)

    NameTypeDefaultDescription
    global_promptSTRING
    text_1STRING
    text_2STRING
    text_3STRING
    text_4STRING
    text_5STRING
    prepend_modeBOOLEANfalse
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    double_promptSTRING