ComfyUI Extension: ComfyUI-PromptChain
A visual tool for prompt randomization and advanced combinations inside of your ComfyUI workflows.
Custom Nodes (0)
README
ComfyUI-PromptChain
A visual tool for prompt randomization and advanced combinations inside of your ComfyUI workflows.
The Problem
Complex prompts with randomization become unreadable fast:
{warrior|mage|rogue}, {iron|steel|mythril} {sword|axe|staff},
{{fire|ice|lightning} enchantment|no enchantment}, {dragon|demon|undead} slayer
Now nest a few levels deeper. Add 20 options per group. Good luck debugging which path fired.
The Solution
PromptChain makes the hierarchy spatial. Instead of parsing nested braces in your head, you see the decision tree as connected nodes:
[Class Node] ──→ [Weapon Node] ──→ [Enchant Node] ──→ [Title Node]
│ │ │ │
warrior|mage iron|steel fire|ice| dragon|demon
|rogue sword|axe|staff lightning |undead slayer
Each node shows exactly what it output. Chain them together, see the whole prompt path at a glance.
Features
- Inline wildcards — Write
red | blue | greendirectly in nodes. No external files required. - Visual chaining — Connect nodes easily to build rich meaningful structures
- Dynamic inputs — Inputs auto-expand as you connect more nodes
- Live preview — See what fired, when it fired, in real-time
- Lock system — Freeze part or all of your nodes for fast testing
- Import/Export — Easily import/export with common DynamicPrompt syntax
- Two modes:
🎲 Randomize Inputs— Pick one path from connected inputs➕ Combine Inputs— Merge all paths together
Installation
ComfyUI Manager: Search "PromptChain" → Install → Restart
Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/mobcat40/ComfyUI-PromptChain.git
Syntax
| Symbol | Meaning | Example | Result |
|--------|---------|---------|--------|
| \| | OR (pick one) | red\|blue\|green | blue |
| , | AND (include both) | red\|blue, dress\|skirt | blue, dress |
Multiline works too — lines ending with | continue the OR group, lines ending with , create AND boundaries.
The Node
PromptChain is the single node type. It has:
- Mode selector —
🎲 Randomize Inputsor➕ Combine Inputs - Text field — Wildcard processing with
|and,syntax - Dynamic inputs — Connect as many inputs as you need, slots auto-expand
Modes
🎲 Randomize Inputs
- Picks ONE random input from connected inputs
- Prepends the text field to the selected input
- Use for branching logic (pick one path)
➕ Combine Inputs
- Merges ALL inputs using breadth-first interleaving
- Tags round-robin across branches so no single branch dominates the token budget
- Example:
["a,b,c,d", "X,Y"]→"a, X, b, Y, c, d"(not"a, b, c, d, X, Y")
Example: RPG Character Generator
Node 1: Node 2 (Randomize): Node 3 (Combine):
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ warrior|mage| │──────→│ steel|mythril │───────→│ fire enchant, │
│ rogue │ │ sword|staff │ │ dragon slayer │
└─────────────────┘ │ input_1: ● │ │ input_1: ● │
└─────────────────┘ └─────────────────┘
Output: "warrior, mythril sword, fire enchant, dragon slayer"
Live Preview
Toggle the Preview checkbox in the node's menubar. When enabled:
- Last run timestamp — Shows elapsed time since execution, updates in real-time (e.g., "Last run: 20 mins ago")
- Selected options — See exactly which wildcards fired
- Full output string — The complete processed result
- Updates on every execution
Lock System
Click the lock icon (🔒/🔓) to freeze the current output.
When locked:
- Node returns cached output instead of re-processing
- Randomization results preserved across executions
- Perfect for keeping a roll you like
Visual indicators:
| State | Appearance | |-------|------------| | Locked | 🔒 Orange icon + bold yellow "Lock" text + gold background overlay | | Unlocked | 🔓 Dim gray icon and text |
Upstream propagation: Locking a node also locks all its input nodes (the entire upstream chain). This ensures your complete prompt path stays frozen — from source nodes all the way to the locked node.
Persistence: Lock state and cached output save with your workflow.
Import & Export
Right-click any PromptChain node → Import or Export
Import: Escape Dynamic Prompts Hell
Paste your existing prompts and auto-generate clean node structures:
| Format | Example | Result |
|--------|---------|--------|
| Plain tags | red, blue, green | Converts to red \| blue \| green |
| Dynamic Prompts | {warrior\|mage}, {sword\|staff} | Creates connected node tree |
| Top-level OR | option A \| option B | Creates separate input nodes |
Nested braces like {a|{b|c}} are recursively expanded into node hierarchies.
Export
Convert your node tree back to Dynamic Prompt format:
- Traverses all connected upstream nodes
- Converts wildcards to brace syntax
- Respects modes: Randomize →
{a|b}, Combine → comma-joined - Dialog with exported string ready to copy
Tag Deduplication
Duplicates automatically removed, first occurrence wins:
Input: "red, blue, RED, green"
Output: "red, blue, green"
Early nodes = intentional placement. Later duplicates from downstream merges get removed.
- Case-insensitive matching
- Special tags like
[BREAK]always preserved
Multiline Wildcards
Lines ending with | form a unified OR group:
warrior |
mage |
rogue
Equivalent to warrior | mage | rogue — pick one randomly.
Why PromptChain?
| Pain Point | Dynamic Prompts | PromptChain |
|------------|-----------------|-------------|
| Nested syntax | {a\|{b\|{c\|d}}} | Visual node tree |
| Debugging | Read the string | See what lit up |
| External files | Required | None |
| Migration | — | One-click import |
Trait Mixing Networks
Wire Randomize nodes in a mesh instead of a tree to create combinatorial trait mixing:
[Fur Type]──┐ ┌──[Randomize]──┐
├──→──┤ ├──→──[Combine]──→ Final Prompt
[Fur Color]─┤ └──[Randomize]──┤
│ │
[Creature]──┴─────[Randomize]─────┘
Each Randomize node acts as selection pressure. Cross-wire your trait pools and every run produces a unique combination - like breeding. A mesh of Shiny Fur | Matted Fur, Silver | Black | Red, and Werewolf | Bear naturally generates creatures like "Red Fur, Shiny Fur, Werewolf" without explicit combinatorics.
Emergent behavior from simple primitives.
Prompt Library Mode
Disconnected PromptChain nodes act as prompt storage:
- Drop a node, paste your prompt, leave it unwired
- Sits on your canvas as a visual "sticky note"
- Saves with your workflow
- Connect it when you want to use it, disconnect to deactivate
Build a library of prompt fragments right in your workflow. Zero config, just nodes.
License
MIT License: free to use forever!