batch random text
Weighted Random Text for Lazy Variety Runs
- STRING
Want different prompts every click, without touching the graph?
You've built a workflow you love. Now you want to click generate and see what happens when the subject changes each run - sometimes a knight, sometimes a dragon, mostly a knight. That's what batch random text is for. Feed it a list of prompt fragments, give each a weight, and it hands back exactly one. Tune the weights and the dice are loaded the way you want: 1, 2, 3 means the third text wins most of the time. It's the "one-click random generator" philosophy this whole pack is built around, and for a text node that's the whole job.
It comes from Moon-NE's MoonNe_Nodes pack, a small grab-bag of lazy-prompt utilities. There's no requirements file and no model downloads - it's pure Python stdlib, which is honestly the best kind of custom node. Nobody's written a love letter to this pack on Reddit (it's genuinely obscure, like single-digit search impressions obscure), so the README is the only doc, and the README literally says "I'm too lazy to write a detailed guide... just plug it into your workflow and figure it out." Fine. Here's the guide.
How it works
The node takes a comma-separated weights string and a list of text inputs, then uses Python's random.choices to pick one entry proportional to its weight. Two bits of defensive coding make it painless:
- If a weight is garbage - you typed
abcor a stray symbol - it's treated as1.0instead of erroring. - If the weight count doesn't match the text count, it pads missing weights with
1.0or truncates extras. Four texts, three weights? No problem, the fourth gets weight 1.
The node seeds its RNG from the seed input, so a fixed seed gives a fixed pick.
The inputs that matter
- weights - the comma-separated weights, one per text. Default
1, 1, 1. - seed - this one matters more than it looks (see the gotcha below).
- text_0, text_1, text_2… - the candidate texts. These are dynamic ports: connect one and the next one appears. They appear under Optional.
Output is a single STRING - the winner. Wire it straight into a CLIP Text Encode node and you're done.
The gotcha that will annoy you
This node has no IS_CHANGED override, unlike the other nodes in this pack. That means ComfyUI will happily cache its output: keep the seed fixed and the inputs unchanged, and you get the same text forever, no matter how many times you hit Generate. The whole point is variety, so this kills it. The fix is in the node's own design: set the seed widget to randomize. That's the intended workflow - the seed input exists specifically to force a fresh pick each run. Forget it and you'll think the node is broken when it's actually just being a well-behaved cache citizen.
Install
Either way, restart ComfyUI after installing. There are no extra dependencies to worry about:
cd ComfyUI/custom_nodes
git clone https://github.com/Moon-NE/MoonNe_Nodes
Or, if you use ComfyUI Manager (and you should - it's the first node anyone should install), just search for MoonNe_Nodes and hit Install. One note: the dynamic text_N ports are added by a JavaScript extension in the pack, so if the extra inputs don't show up after you install, do a hard refresh of the browser tab (or restart ComfyUI) before you blame the node.
One last tip: if you pipe this into a modern LLM-encoded model like Flux 2 Klein, Z-Image, or Anima, keep the fragments as plain words - those models discard SDXL-style (tag:1.3) weight syntax anyway. This node picks the text; what the text does to your image is between you and your checkpoint.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| weights | STRING | 1, 1, 1 | — |
| seed | INT | 00–18446744073709550000 | — |
| text_0opt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |