Text randomizer
The Text randomizer node
- text
The Dynamic Prompts gap, filled by a 20-line node
If you came from A1111, you remember Dynamic Prompts: write {decrepit|luxurious|whimsical} in a prompt and every generation picks one option at random. Stock ComfyUI has no equivalent - the {a|b} syntax some packs sneak in belongs to Impact Pack, and core gives you nothing. This node is that feature, standalone: type [man|girl], sitting on a [bench|grass] and each run rolls one of the four combinations. No API, no key, no model files. It's a few lines of pure Python, and that's the whole point.
Why you'd actually reach for it
In ComfyUI the prompt is just a STRING that flows into the text encoder and then into conditioning. This node sits in front of that chain and writes the string for you. That's genuinely useful for exploration: lock your sampler and steps, randomize the subject, the lighting, the camera - and get a contact sheet of compositions instead of one image. It pairs perfectly with seed-farming (DPM++ 2M @ 10-15 steps to hunt seeds, per the standard advice) because you can farm prompts the same way. On LLM-encoded models like Z-Image or Klein, where the prompt is an instruction rather than a token bag, randomized sentence blocks work surprisingly well too.
How it works
The mechanism is simple and worth understanding, because it explains two of the node's quirks. Every [...] group is split on | and one option is chosen at random; anything outside the brackets passes through untouched. The replacement loops until no brackets remain, so nesting works - [a [b|c] d] resolves inner first. And a trailing | creates an empty option, so [apple|] is a 50/50 chance of nothing, [apple||] is 33/67. Handy for "sometimes no animal at all".
The important quirk: the node calls random.seed(seed) on every execution. Same seed, same pick, always - deterministic, not random. Which means the default seed of 0 always produces the exact same prompt. This is the trap. If you click Generate and get the identical prompt every time, it isn't broken; it's the default seed. Change the seed, or wire it to a varying seed source, or you'll never see the variety you installed this for.
Inputs and outputs that matter
Only two inputs, both self-explanatory:
- text (multiline) - your template.
|separates options;[and]delimit groups;[x|]adds a chance of nothing. - seed (INT, 0 to 2^64-1, default 0) - makes the pick reproducible. This is the one you'll actually fiddle with.
The single output, text (STRING), wires straight into a CLIPTextEncode (or whatever your model's encoder node is called). If you want to see what it produced before it goes to the encoder, the same pack ships a Show Text node for exactly that.
Installing it
This is about as painless as custom nodes get. Either open ComfyUI Manager → Install Custom Nodes and search for comfyui-text-randomizer, or:
cd ComfyUI/custom_nodes
git clone https://github.com/nosiu/comfyui-text-randomizer
Restart ComfyUI. There's no requirements.txt, no dependencies beyond Python's standard library, no model downloads. If you've ever installed a node that pulled in torch, you'll appreciate how boring this one is.
Where people get burned
- Same output every run - see above: seed 0 is deterministic. Change the seed or feed it one that varies.
- A bracket left unclosed - no error, the literal
[just rides along into your prompt. Silent and confusing. The pack's "Text randomizer with check" variant exists to catch exactly this. - Overdoing nesting - deep nested groups work, but they're a debugging headache. Split the variety across two randomizer nodes and a ConcatText instead.
It's a quiet little node from a one-commit solo maintainer, not a famous pack. Don't expect a community or an issue tracker with answers. Expect it to just work, because it's short enough to read in one sitting.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| seed | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |