String Random
One prompt, five options, and a seed that lets you go back
- string
What it's for
The community's oldest trick for prompt variety is A1111's bracket syntax - a woman with {brown|blonde|black} hair - and the KB's prompt-engineering doc notes it's mostly people who arrived after 2024 who've never heard of it. Brackets are great for a word or a phrase. They're useless for whole prompts: a lighting paragraph, a camera setup, three alternate scene descriptions. Cramming paragraphs into braces makes a prompt nobody can read.
String Random is the node version: paste a list of prompt variations into one text box, split by dashes or newlines, and let a seed pick one. Same seed, same pick - every time, forever. That's the feature that actually earns it a slot, because it means when the dice land on something good you can lock the seed and keep generating from that exact prompt.
How it works
custom_text is split into items in a fixed priority order, and this is the part worth understanding because it decides what your list looks like:
- If any line is only dashes (
---), the text splits on those lines. - Otherwise, if there are any newlines, it splits per line.
- Otherwise it falls through to sentence punctuation -
./。, then;/;, then,/,.
Each item is then stripped of surrounding whitespace, and matching wrapping quotes are removed, so a line of "wide shot, golden hour" comes out without the quote marks. Empty items are dropped. Then random.seed(seed) and random.choice - deterministic, and it re-seeds from your value every execution rather than pulling from a global stream, so it doesn't drift when you re-run or re-queue.
If custom_text is empty you get an empty string, which means a prompt wired from this node can silently blank out your conditioning if you forget to fill the box.
The node also pushes the chosen item into its own UI preview, so you can see which one it picked without a text-preview node. Small thing, genuinely handy.
Inputs and outputs
custom_text (multiline STRING, default empty), seed (INT, 0 to 1125899906842624, default 42). One output: string.
The seed widget gets ComfyUI's usual control_after_generate behaviour, and it's the entire workflow:
- leave it on randomize and every run picks a new item - generate 16 images and you get 16 different prompts;
- set it to fixed when one lands, and now you can iterate on steps, CFG and the checkpoint with the prompt held constant.
Wire string into your CLIP text encode, or into a text-concat node ahead of it. Note that the node emits one string per execution - it doesn't produce a different prompt per image in a batch, so batch variety comes from running again with a new seed, not from within one queue.
Install
ComfyUI Manager → search 1hewNodes, or:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Restart. Zero extra dependencies for this one - it's standard library random and re. (The pack's requirements.txt installs a lot more for its detection and video nodes; you don't need any of it here.) The pack is built on the current comfy_api.latest schema, so a very stale ComfyUI install will refuse to load it.
Common issues
"It gave me a fragment, not a prompt." Your list had no dashes and no newlines, so it fell through to punctuation and split your single-line prompt on commas. If you want a list, put each option on its own line or separate them with a --- line.
A line disappeared. A line consisting only of dashes is treated as a separator and consumed. Also, empty or whitespace-only lines are dropped, so don't rely on blank lines to break up the box visually.
Quotes vanished from the start and end of an item. That's the quote-stripping. If you genuinely want a leading quote character, add something before it.
You keep getting the same pick. control_after_generate is probably set to fixed/increment rather than randomize - or you're re-queuing a cached execution and the node never re-ran. Queue with a fresh prompt batch or set the seed to increment.
Why not just use brackets? Do - for a word or two. This node is for when each alternative is a paragraph, or when you want the choice to be reproducible independently of the rest of the seed.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| custom_text | STRING | — | |
| seed | INT | 420–1125899906842624 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |