ComfyUI Node

Random List Picker

Randomize your prompts without touching the LLM (it's the best node in the pack)

By mattjohnpowell·Created 2 years ago·Updated 3 months ago· 60
Random List Picker
    • selected_item
    • prompt
    • item_count
    • selected_index
    itemsrock pop jazz::2 classical hip-hop
    template
    prefix
    suffix
    exclude
    fallback
    count1
    separator,
    caseoriginal
    modepick
    seed-1

    Here's the thing nobody tells you about this pack: the Random List Picker is the node you'll use most, and it has nothing to do with LM Studio. It's a pure prompt-utility - paste a newline-separated list of anything, and every run it picks a random one (or several) and assembles a ready-to-use prompt string. It doesn't need a server, a model, an API key, or even LM Studio installed. You could clip it out of this pack and never notice it was supposed to ship with an LLM suite.

    Randomness in prompts is a classic ComfyUI move - the community's been wrapping alternatives in {this|that|the other} wildcards and batching for years to generate variety without writing more prompts. This node is that idea with a bigger toolbox: weighted picks, templates, exclusions, and a seed you can pin for reproducibility. If you're generating variations, character-reference libraries, or just don't want to hand-write fifty prompts, this is the honest path.

    The inputs that matter

    • items (required) - one item per line. The weighted syntax is the fun part: append ::weight and it gets proportionally more likely, so jazz::3 is three times as likely as a plain pop. Default weight is 1. Empty lines are ignored.
    • template - a prompt with {item} as the placeholder, e.g. Create a {item} song with heavy bass. When set, this overrides prefix/suffix. When count is more than 1, the picked items are joined with the separator first, then substituted in.
    • prefix / suffix - used when template is empty. Prepends and appends text around the picked item(s).
    • exclude / fallback - exclude a newline-separated list of items you never want (case-insensitive), and if the list ends up empty after exclusions, fallback is what comes out.
    • count - how many unique items to pick. Capped at list size automatically.
    • separator - how multiple picks are joined. Default ", ".
    • case - original | uppercase | lowercase | title | sentence. Instant case transformation per item.
    • mode - pick grabs random item(s); shuffle returns the entire list in a random order.
    • seed - -1 for a new random result every run; pin any other value to reproduce a specific draw.

    Outputs

    Four pins. selected_item is the chosen item(s) joined with the separator; prompt is the fully assembled result (template or prefix+item+suffix) - wire that straight into CLIP Text Encode or a Text Gen node. item_count tells you how many usable items survived exclusions, and selected_index gives the zero-based position of the first pick (-1 in shuffle mode), which is handy if you want other nodes to react to which item got chosen.

    A concrete example: three random genres, weighted toward jazz:

    items:
      rock
      pop
      jazz::3
      classical
      hip-hop
    
    count: 3
    template: Generate artwork combining {item}.
    

    Each run you get something like Generate artwork combining watercolour, impressionist, cyberpunk. - same template, different material every time. One light aside: the ::weight syntax is a per-line thing, so if your items legitimately contain :: (a namespace, a file path), you'll want to check how they parse - it's an edge case, but it exists.

    Install and gotchas

    Install exactly like the rest of the pack - ComfyUI Manager (search "LM Studio"), or git clone https://github.com/mattjohnpowell/comfyui-lmstudio-image-to-text-node into custom_nodes - but you don't need to bother with pip install lmstudio or a running server for this one. It's plain Python; it just works. The only real gotchas are the ones you create: forgetting a template/prefix/suffix so the output is a bare item, or a seed pinned when you actually wanted variety. Set it to -1 and let it roll.

    The reason it lives in an LLM pack is probably the author's own workflows - a random genre feeds the Text Gen node, which writes the prompt. And honestly, using them together is a great loop: let the picker inject the subject, let the local LLM handle the prose. But standing alone, it's a genuinely useful little utility that deserves more than its zero Google impressions.

    Categoryutils

    Inputs (11)

    NameTypeDefaultDescription
    itemsSTRINGrock pop jazz::2 classical hip-hopOne item per line. Empty lines are ignored. Weighted syntax: item::weight (e.g. jazz::3 is 3× more likely). Default weight is 1.
    templateoptSTRINGPrompt template with {item} as a placeholder. Example: 'Create a {item} song with heavy bass.' When count > 1, items are joined with the separator before substitution. Overrides prefix/suffix when non-empty.
    prefixoptSTRINGText prepended before the chosen item(s). Used when template is empty.
    suffixoptSTRINGText appended after the chosen item(s). Used when template is empty.
    excludeoptSTRINGItems to never pick, one per line. Matching is case-insensitive.
    fallbackoptSTRINGValue returned when no items remain after exclusions.
    countoptINT11–100Number of unique items to pick. Automatically capped at list size.
    separatoroptSTRING, String used to join multiple picked items (e.g. ', ' ' | ' '\n').
    caseoptCOMBOoriginalCase transformation applied to each picked item.
    modeoptCOMBOpickpick – choose random item(s) from the list. shuffle – return the entire list in a random order.
    seedoptINT-1-1–2147483647Random seed. Use -1 for a new random result each run.

    Outputs (4)

    NameTypeDescription
    selected_itemSTRING
    promptSTRING
    item_countINT
    selected_indexINT