Random Tag Weights
A dice roll for your prompt's emphasis
- modified_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):
- It first finds anything already in
(tag:1.0)form. Withpreserve_existing_weightsON those are kept exactly as written; otherwise they get re-rolled like everything else. - Parenthesized groups like
(small bird)are treated as a single tag rather than split apart - handy when the whole phrase is one concept. - The remaining plain text is split into tags, by commas (default) or by spaces.
- Each tag gets a uniform random weight between
min_weightandmax_weight, rounded to two decimals. Tags landing belowthresholdare dropped entirely. - If
shuffle_tagsis on, the order is randomized (seedable, like everything here), trimmed tomax_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
thresholdis higher than most rolls. Lower it or widen the weight range. (tag:1.0)pairs didn't change -preserve_existing_weightsis 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.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | Default input text if no external input_text is provided. | |
| min_weight | FLOAT | 0.00–10 | The lowest possible random weight assigned. |
| max_weight | FLOAT | 1.30–10 | The highest possible random weight assigned. |
| threshold | FLOAT | 0.00–10 | Tags with generated weight below this value are discarded. |
| max_tags | INT | 301–10000 | Maximum number of tags allowed in the output. |
| seed | INT | 00–18446744073709550000 | Random seed for consistent repeatable output. |
| shuffle_tags | BOOLEAN | true | Randomize the order of output tags. |
| detect_by_commas | BOOLEAN | true | If ON: tags are split by commas. If OFF: tags are split by spaces. |
| group_parentheses | BOOLEAN | true | If ON: anything inside (...) is treated as one tag. |
| preserve_existing_weights | BOOLEAN | false | If ON: tags already containing weights (tag:1.0) will not be modified. |
| output_with_commas | BOOLEAN | true | Choose output format: commas or spaces between final tags. |
| add_random_commas | BOOLEAN | false | If ON: randomly insert commas between tags at the end. |
| num_random_commas | INT | 11–100 | Number of commas to randomly insert between tags. |
| input_textopt | STRING | External text input from another node. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| modified_text | STRING | — |