ComfyUI-DynamicPrompts is a custom nodes library that integrates into your existing ComfyUI Library. It provides nodes that enable the use of Dynamic Prompts in your ComfyUI. The nodes provided in this library are:
- Random Prompts - Implements standard wildcard mode for random sampling of variants and wildcards.
- Combinatorial Prompts - Iterates through every possible combination of random values in a prompt.
- I'm Feeling Lucky - Uses the given prompt to download a related prompt from Lexica.art.
- Magic Prompt - Employs a neural network to add relevant modifiers to your prompt.
- Jinja2 Templates - Allows you to write prompts using Jinja2 templates.
Nodes can be found in the Dynamic Prompts menu:

- Dynamic Prompts Home
- Dynamic Prompts Syntax
- Dynamic Prompts Extension for Auto1111
- Tutorial
- Online Resources
- CHANGELOG
- Stable Diffusion SDXL Wildcards and ComfyUI
- Install ComfyUI-Manager if it isn't already.
- Press Install Custom Nodes from the ComfyUI-Manager menu
- Search for dynamicprompts
- Click install
Follow the steps below to install the ComfyUI-DynamicPrompts Library. These commands assume the your current working directory is the ComfyUI root directory.
- Clone the repository:
git clone https://github.com/adieyal/comfyui-dynamicprompts custom_nodes/comfyui-dynamicprompts - Install the required Python packages:
python -m pip install -r custom_nodes/comfyui-dynamicprompts/requirements.txt - Run install.py:
python custom_nodes/comfyui-dynamicprompts/install.py mkdir custom_nodes/comfyui-dynamicprompts/wildcards- (Optional) download a wildcard collection and copy it into this new wildcards folder.
- Restart your ComfyUI.
- Example workflows can be found in
custom_nodes/comfyui-dynamicprompts/example_workflows.
The extension looks for wildcard files in custom_nodes/comfyui-dynamicprompts/wildcards. It supports wildcard files in .txt, .json and .yaml (example format).
There are many pre-built wildcards collections available. Here are a few to get you started:
All nodes in this library produce a String output that can typically be passed into Clip Text Encode Prompts. Both positive and negative nodes are supported.
Please note, since ComfyUI is inherently stateless, some nodes might have a slightly unexpected behavior:
-
The Combinatorial Prompt generation iterates through all possible values in a cycle. For example, A
{red|green|blue}ball will generate the following sequence:- A red ball
- A green ball
- A blue ball
- A red ball
- ...
-
The I'm Feeling Lucky, Magic Prompt, and Jinja2 nodes have an optional auto refresh parameter. If set to
True, a new prompt is generated for every iteration. However, if set toFalse, a prompt will be downloaded once and used for subsequent generations.
- This is a quick and dirty release with some known limitations such as non-configurable random seeds, inability to select the MagicPrompt model, and absence of several other configuration features.
- Currently, the only way to view the generated prompt is through console output. A future release will introduce nodes to display the generate prompt on screen and to write it to a file.
- It is not currently possible to chain generators, this functionality will be added in future releases.
- The installation script will be automated in the future for ease of use.
Since the original repository is presumably not actively maintained at the moment, I decided to fork the repo and make some fixes and some custom changes as well. The changes are based on my personal preferences and use-cases, but they may be useful for others as well.
Shoutout to adieyal for providing this great library in the first place!
This should be a more or less comprehensive list of changes I made:
- Merged changes done by do49
- Disabled sorting of wildcards
- Made changes to allow a single node to switch between C and R modes, meaning the two modes:
random- Generate a single random prompt based on wildcards in the prompt text (default)combinational- Generate all possible prompts based on wildcards in the prompt text (see sd-dynamic-prompts readme)- Note: Be aware that if a lot of wildcards and/or large wildcard-sets are used, the number of possible prompts can grow exponentially and interrupt is usually not possible at this point. Even though only a single prompt is returned at a time (but more invocation + seed), all possible combinations are (most likely) prepared in memory ahead of time.
- Added new
DPRandomGeneratorAdvancednode- Renamed
modeinput (see feature above) tosampling_modefor clarification and distinction - Added new
refresh_modeinput with two options:always- Always trigger/re-evaluate the node by resetting theIS_CHANGEDstate (original behavior)- This must be enabled in case
combinationalmode is used to generate all possible prompts using the same seed
- This must be enabled in case
on_value_change- Only trigger/re-evaluate the node when any input value (text, seed, etc.) has changes (new default behavior)- This is likely the preferred behavior for most use-cases, including
combinationalmode in case the same prompt should be reproduced multiple times
- This is likely the preferred behavior for most use-cases, including
- Added new
console_outputinput with two options:off- Do not print the generated prompt to the console (new default behavior)- I often times modify the prompts afterwards and use nodes to display the final prompt and save it in the metadata
final_prompt- Print the generated prompt to the console (original behavior)debug- Print the generated prompt and additional information to the console (only IS_CHANGED hash for now)
- Renamed
- Updated the original
DPRandomGeneratornode to use the newDPRandomGeneratorAdvancednode with my preferred default settings (fixed values, both inputs are gone to safe space)sampling_modeset torandomrefresh_modeset toon_value_changeconsole_outputset tooff

