Nodes/ComfyUI-RandomTagWeights/Random Tag Weights
ComfyUI Node

Random Tag Weights

A dice roll for your prompt's emphasis

By Analaser·Created 11 months ago·Updated 8 months ago· 1
Random Tag Weights
    • modified_text
    text
    min_weight0.0
    max_weight1.3
    threshold0.0
    max_tags30
    seed0
    shuffle_tagstrue
    detect_by_commastrue
    group_parenthesestrue
    preserve_existing_weightsfalse
    output_with_commastrue
    add_random_commasfalse
    num_random_commas1
    input_text

    You've got a prompt you like, but you're tired of generating the same image fifty times. Random Tag Weights is the "roll the dice" button for prompt emphasis: feed it your tag list and it rewrites every tag as a (tag:weight) pair with a freshly randomized number, so one source prompt can explore a whole neighborhood of outputs. It's a one-trick node, but the trick is genuinely handy for character studies, composition experiments, and anyone who batch-generates a lot.

    The author ships it in one file, one node, under the Text category. There are no models to download, no GPU work, no extra Python packages - it's just random and re, the standard library, doing string surgery on your prompt. Install it and it's immediately useful.

    How it actually works

    The node takes your text, then processes it in passes (this is from the source, not the marketing):

    1. It first finds anything already in (tag:1.0) form. With preserve_existing_weights ON those are kept exactly as written; otherwise they get re-rolled like everything else.
    2. Parenthesized groups like (small bird) are treated as a single tag rather than split apart - handy when the whole phrase is one concept.
    3. The remaining plain text is split into tags, by commas (default) or by spaces.
    4. Each tag gets a uniform random weight between min_weight and max_weight, rounded to two decimals. Tags landing below threshold are dropped entirely.
    5. If shuffle_tags is on, the order is randomized (seedable, like everything here), trimmed to max_tags, and joined back into (dog:1.2), (cat:0.9) style output.

    The output is one STRING, modified_text, and it wires straight into a CLIP Text Encode node's text input in place of your prompt. That's the whole data flow.

    The inputs that actually matter

    You'll set most of these to defaults and forget them, but these few are the ones you'll touch:

    • text - your starting tag list. Plain Danbooru-style tags (1girl, long hair, park) work best.
    • min_weight / max_weight - the range the dice rolls. This is the heart of it. The practical attention range on CLIP-era models is roughly 0.5–1.5; below 0.5 a concept barely registers and above 1.5 you get oversaturation. Defaults of 0–1.3 are fine, but if you want subtle variation, narrow it to 0.9–1.2 instead of gambling on 0.0.
    • threshold - the discard line. Tags rolled under this get cut, which is how this node doubles as a tag filter that keeps only the "strong" concepts.
    • seed - set it for reproducibility, change it to re-roll. Also controls the shuffle order, so a fixed seed pins the whole output, not just the weights.
    • max_tags - caps how many tags survive, default 30. Useful when your source list is huge and you want a trimmed prompt.

    The rest - shuffle_tags, detect_by_commas, group_parentheses, preserve_existing_weights, output_with_commas, and the odd add_random_commas/num_random_commas pair (which drop stray commas into the output for the "natural prompt" crowd) - are quality-of-life toggles. The optional input_text input overrides the text field, so you can drive this from another node instead of typing by hand.

    The one gotcha that matters

    This node emits CLIP attention syntax, and CLIP attention syntax only means something to CLIP-encoded models: SD 1.5, SDXL, Illustrious, NoobAI, Pony. On LLM-encoded models (Flux, Z-Image, Anima, Chroma), (tag:1.3) isn't parsed - it's fed to the encoder as literal punctuation, which is worse than no weighting at all. So point this at a tag-friendly checkpoint and it'll sing; hook it to a Flux workflow and you're just making your prompt uglier for nothing.

    Installing it

    Two ways, both easy. ComfyUI Manager (search ComfyUI-RandomTagWeights) is the one I'd use:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Analaser/ComfyUI-RandomTagWeights
    

    Then restart ComfyUI. That's it - the node appears under Text. No requirements.txt, no model files, no manager warnings about missing deps. It's a rarity: a custom node that can't break your environment.

    Troubleshooting

    • Output looks empty or tiny - your threshold is higher than most rolls. Lower it or widen the weight range.
    • (tag:1.0) pairs didn't change - preserve_existing_weights is ON. Flip it off to re-roll everything.
    • Weights feel like nothing happened - you're on a Flux/Z-Image-class model where the syntax is inert. Switch to an SDXL/Illustrious checkpoint or drop the node.
    • The author is a one-person hobby project ("donate so I can get a 5090" in the README, announced on r/comfyui and r/StableDiffusion in October 2025). It's a small, honest utility - if it breaks, the GitHub issues tab is the support channel, and the fix is probably a restart.

    For serious batch variety this pairs well with a seed-cycling workflow. It won't write your prompts for you, but it'll stop you from hand-editing 1.2 to 1.1 a hundred times.

    Categorytext

    Inputs (14)

    NameTypeDefaultDescription
    textSTRINGDefault input text if no external input_text is provided.
    min_weightFLOAT0.00–10The lowest possible random weight assigned.
    max_weightFLOAT1.30–10The highest possible random weight assigned.
    thresholdFLOAT0.00–10Tags with generated weight below this value are discarded.
    max_tagsINT301–10000Maximum number of tags allowed in the output.
    seedINT00–18446744073709550000Random seed for consistent repeatable output.
    shuffle_tagsBOOLEANtrueRandomize the order of output tags.
    detect_by_commasBOOLEANtrueIf ON: tags are split by commas. If OFF: tags are split by spaces.
    group_parenthesesBOOLEANtrueIf ON: anything inside (...) is treated as one tag.
    preserve_existing_weightsBOOLEANfalseIf ON: tags already containing weights (tag:1.0) will not be modified.
    output_with_commasBOOLEANtrueChoose output format: commas or spaces between final tags.
    add_random_commasBOOLEANfalseIf ON: randomly insert commas between tags at the end.
    num_random_commasINT11–100Number of commas to randomly insert between tags.
    input_textoptSTRINGExternal text input from another node.

    Outputs (1)

    NameTypeDescription
    modified_textSTRING