PD: Random Prompt
Spinning up prompt variations without a second thought
- STRING
Say you're generating a sticker pack and want a dozen playground items in the same art style - swing, slide, sandbox, merry-go-round. You could hand-type forty prompts, or you could let this node build the combinations and feed them straight into a batch. That's PD: Random Prompt: a list of things, a fixed template, and it cross-products them into ready-to-encode prompts, with an option to shuffle or just take the first N.
The default template ships with the exact use case baked in: the mutable list is a pile of playground equipment, and the immutable prompt is sticker, Cartoon, `` - the backtick placeholder is where each item gets dropped in. It's a template engine with one placeholder, and that's most of what you need for batch variation.
How it works
It reads mutable_prompt line by line (one item per line, blank lines stripped) and treats immutable_prompt as a template. Any line containing `` gets the placeholder replaced with each mutable item; a template without the placeholder gets , `` appended so the item lands at the end. Every mutable item × every template line becomes one prompt. Then:
random_sample = enableshuffles withrandom.sample;disabletakes them in order.max_countcaps the output (default 9, up to 1000).- If you set
seedto anything nonzero, it seeds Python'srandomso the same run is reproducible. Seed 0 means "don't bother" - you'll get a different shuffle every run.
The output is a list of strings (the node declares OUTPUT_IS_LIST), so it's meant to be fed into something list-aware downstream - a batch image saver, a queue, or a node that iterates prompts. A progress bar shows up during generation, which is a nice touch from the pack.
The inputs that matter
mutable_prompt- your variable items, one per line. The default playground list is a decent demo; you'll replace it.immutable_prompt- the fixed template; use``as the item placeholder.random_sample-enable/disable.max_count(1–1000) - cap on how many prompts come out.seed(optional) - lock it for reproducibility.
Installing it
Part of Comfyui_PDuse by 7BEII. ComfyUI Manager (search "PDuse") or:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse.git
cd Comfyui_PDuse
pip install -r requirements.txt
Restart. No models to download - the pack's deps are numpy, Pillow, scipy, opencv-python, torchvision. Chinese-first docs (Feishu/Bilibili).
Where people get burned
The biggest gotcha: the output is a list, and a regular CLIP Text Encode node doesn't take lists. You need a list-aware encoder or a batch/queue system downstream, or you'll get a type error and a confused afternoon. Second, shuffling happens once per run over the built combinations, not per line - two runs with the same seed give the same prompts, but "same seed, different run" only holds if you actually set one. Third, max_count caps but doesn't pad: if you ask for 9 and only built 4 combos, you get 4. If you want every combination, set random_sample = disable and max_count high.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| max_count | INT | 91–1000 | — |
| mutable_prompt | STRING | Swing Slide Climbing frame Sandbox See-saw Merry-go-round Jungle gym Trampoline Monkey bars Rocking horse Playhouse Hopscotch Balance beam Spring rider Water play area Ball pit Tunnel Zip line Basketball hoop Bicycle rack Spinner Climbing wall Rope ladder Tetherball Flying fox Swinging bridge Spiral slide Water sprinkler Pedal go-kart Miniature golf course | — |
| immutable_prompt | STRING | sticker, Cartoon, `` | — |
| random_sample | COMBO | 2 options: enable, disable | |
| seedopt | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |