Nodes/ComfyUI-LogicUtils/Weighted Random Choice
ComfyUI Node

Weighted Random Choice

Pick from a list where some options are more likely than others

By aria1th·Created 3 years ago·Updated 7 months ago· 116
Weighted Random Choice
    • STRING
    input_stringapple|10$banana|1$orange|3
    separator$
    seed0

    Plain wildcard-style randomization gives every option an equal shot. Weighted Random Choice doesn't - you tell it "banana should come up ten times more often than orange," and it respects that. It's the node for when you want variety in a batch but you also want to bias it: mostly one style with the occasional wildcard, mostly your best sampler with a rare test of another, that kind of thing.

    The format is right there in the default value: apple|10$banana|1$orange|3. Each entry is item|weight, entries are joined by whatever you set as the separator ($ by default). Given that string, apple is roughly 10× as likely to be picked as banana, and orange sits in between. Swap in your own items - prompt fragments, style names, LoRA identifiers, whatever a downstream text node expects - and the weights work the same way regardless of what the strings actually mean to you.

    How it works

    It parses input_string into item/weight pairs using separator, then does a weighted random draw seeded by seed. Same seed, same draw - that's what makes it usable in a reproducible workflow rather than just a slot machine. It's also marked as an output node, so ComfyUI shows you the result it picked directly on the node, not just downstream.

    The inputs and outputs that matter

    • input_string - the pool of choices as item|weight pairs. Default apple|10$banana|1$orange|3 shows the format; replace it with your own list.
    • separator - what splits the entries apart. Default $, change it if your item text needs to contain a dollar sign.
    • seed - controls which pick you get. Fix it for a reproducible choice, or drive it from ComfyUI's normal seed controls for variation across a batch.
    • Output - STRING, the item that got picked (weight stripped off). Wire it straight into whatever text field is downstream - a prompt, a filename, another logic node.

    How to install it

    It's part of the full LogicUtils pack. Via ComfyUI Manager, search ComfyUI-LogicUtils, install, restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aria1th/ComfyUI-LogicUtils
    

    then restart ComfyUI. No models, no heavyweight dependencies - this is string parsing and Python's random, nothing more.

    Some background worth having: the author is aria1th, better known publicly as AngelBottomless - the trainer behind Illustrious XL, the SDXL anime finetune that displaced Pony Diffusion v6 as the open-source default. LogicUtils is a side project, and the README says plainly where the docs stand: "Proper documentation is being prepared, however there are too many nodes." That hasn't changed since the repo went quiet in early 2026, when his public work moved off image generation entirely. It's a real, used pack regardless - it turns up as a listed dependency in complex published workflows alongside rgthree-comfy and comfyui-kjnodes - people just work out how each node behaves from its defaults, same as this article does.

    Common issues & troubleshooting

    It only ever picks the low-weight items, or never picks them at all. Double-check your weights parsed the way you think - a stray extra | or a typo in the separator will silently break the split and the node may fall back to something unexpected rather than erroring loudly. Print the input_string through Text Preview (same pack) if you're building it dynamically and want to see exactly what's arriving.

    Same result every single run. That's seed doing its job - it's fixed unless you change it. If you want variety across a batch, drive it the way you'd drive any other seed input in ComfyUI.

    Item text itself contains your separator character. Change separator to something that won't collide with your data - a pipe, a semicolon, whatever your item strings won't naturally contain.

    CategoryLogic Gates

    Inputs (3)

    NameTypeDefaultDescription
    input_stringSTRINGapple|10$banana|1$orange|3
    separatorSTRING$
    seedINT00–9223372036854776000

    Outputs (1)

    NameTypeDescription
    STRINGSTRING