Random Text (Seed)
Same seed, same file — the reproducible random prompt node
- text
- text_path
- debug
You've got a folder of 200 prompt files and you want a different one on every run - but you also want to be able to go back and reproduce the image that a specific prompt produced. That's the exact problem Random Text (Seed) exists for. It picks a random text file out of a folder, drops its contents into your workflow as a string, and ties the pick to a seed. Same seed, same file. Bump the seed, get a different file. It's the "random prompt" workflow with a handbrake on.
Why not just use wildcards? The Impact Pack's __wildcard__ and {a|b|c} syntax (which most people learned from A1111) will happily do random substitution - and that's the pack's own honest complaint about the genre: wildcard implementations are weak at actual randomness, and more importantly they give you no way to re-see a particular pick after the fact. This node makes the random choice itself a first-class, reproducible input.
How it works
When the node runs, it collects every file in folder whose name ends with one of the comma-separated extensions (default .txt,.prompt,.md), then builds a private random.Random(seed) and calls .choice() on the list. The "private" part matters: it doesn't touch ComfyUI's global RNG, so this node neither consumes entropy other nodes rely on nor gets disturbed by them. ComfyUI's caching respects the seed too - the node's change signature is derived from folder + seed + settings, so it re-runs exactly when you change the seed and skips wasted work otherwise.
Inputs and outputs
Honestly, only two inputs matter on day one:
folder(required) - an absolute path to your prompt library. No shortcut.seed(required) - any integer up to 2^64−1.
The rest are optional with sane defaults: include_subfolders walks the tree, extensions (add your own, comma-separated), encoding (utf-8) and errors (replace) for reading files, and debug_info.
Outputs:
text- the file's contents as a STRING. Wire it straight into CLIP Text Encode, positive or negative, or anything else that takes a string.text_path- the full path of the file that won. Handy for knowing what actually got picked; feed it to a display node.debug- an empty string unlessdebug_infois on, then a one-line summary (mode, file count, picked filename).
Install
ComfyUI Manager: search "LoadRandomText", install, restart. Or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/thezveroboy/ComfyUI-LoadRandomText
Then restart ComfyUI. That's the whole install - there's no requirements.txt, no models, no torch-heavy dependency. The pack is pure Python standard library, so this is genuinely a one-step deal.
Common issues
- "Folder ... cannot be found" - you typed a relative path or fat-fingered it. Give the absolute path.
- "No valid text files found" - your files don't match
extensions. If you use.cfgor.json, add them to the comma-separated list. - The reproducibility caveat. Same seed → same file only while the folder is unchanged. Add, remove, or rename a file and every seed's pick shifts (the source doesn't sort the file list, so this isn't even guaranteed to match across operating systems). Treat your prompt folder as read-only during a batch and you're fine.
- Garbled characters in the text - the defaults are
encoding=utf-8witherrors=replace, so a file saved in another encoding (say, Cyrillic cp1251) won't crash the node but will render replacement characters. Setencodingto match your files.
This is the unglamorous, correct version of a common need. If your prompt library is stable, it's the node in the pack you'll actually reach for.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| folder | STRING | — | |
| seed | INT | 00–18446744073709550000 | — |
| include_subfoldersopt | BOOLEAN | false | — |
| extensionsopt | STRING | .txt,.prompt,.md | — |
| encodingopt | STRING | utf-8 | — |
| errorsopt | STRING | replace | — |
| debug_infoopt | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| text_path | STRING | — |
| debug | STRING | — |