ComfyUI A1111-like Prompt Custom Node Solution
How does it work?
- This repository contains:
- The script
comfyui_a1111_prompt_array_generator.pyfor generating the required workflow block because it'd be extremely tedious to create the workflow manually. - Two new ComfyUI nodes:
CLIPTextEncodeA1111: A variant ofCLIPTextEncodethat converts A1111-like prompt into standard promptRerouteTextForCLIPTextEncodeA1111: A kind ofRerouteforTextdata type. Workaround for a ComfyUI bug that prevents Primitive node from being connected with Reroute node
- The script
The idea is each step would require a positive CLIPTextEncodeA1111 node, a negative CLIPTextEncodeA1111 node and a KSamplerAdvanced node. Each node would have information on which particular step it's processing on. Then the CLIPTextEncodeA1111 node would based on its step information to convert the A1111-like prompt to the actual prompt to be sent to the KSamplerAdvanced of that step.

Syntax
- Alternating Words
[foo|bar]: step 0 isfoo, step 1 isbar, step 2 isfooand so on. Three or more words are also supported. - Prompt Editing
[foo|bar|0.3]: Usesfoofor the first 30% of the steps andbarfor the remaining steps- Warning: This is incompatible with A1111! It uses
|instead of:to avoid conflict with the embedding syntax of ComfyUI. - Detection algorithm: If it's three words and the last one is a number, it's Prompt Editing. Otherwise it's Alternating Words
- Warning: This is incompatible with A1111! It uses
- Recursion is supported. Example:
[[foo|bar]|baz|0.6]means usingfooandbarevery other step for the first 60% of steps, then usebazfor the remaining steps
Installation and Usage
Option A: Quick Start
- Copy
custom_nodes/clip_text_encoder_a1111.pyto thecustom_nodesdirectory of ComfyUI - Quick Start: Load ./docs/sample_workflow_50steps.json and that's it!
Option B: Build your own workflow
- Copy
custom_nodes/clip_text_encoder_a1111.pyto thecustom_nodesdirectory of ComfyUI - Run
python3 comfyui_a1111_prompt_array_generator.py 50 > workflow.json. A workflow block would be generated as shown below:- Usage:
python3 comfyui_a1111_prompt_array_generator.py <steps> [step_start inclusive (default:0)] [step_end exclusive (default:max)]
- Usage:
- Load the newly generated
workflow.jsonto ComfyUI- Advanced usage: Use CTRL+Drag to select multiple nodes and then CTRL+C to copy the workflow block. Then you can use CTRL+V to paste the workflow block to another window.
- Manually build the workflow around it and enjoy! And example is shown below:

TODO
Implement a script that converts any existing workflow into the one that utilizes CLIPTextEncodeA1111, which'd enable controlnet support.


