Token Replace
Build prompts from templates instead of by hand
- result
If you've ever wanted to run twenty variations of the same prompt where only the subject changes, you know the pain of retyping it each time. Token Replace automates that: you write a template once with placeholder tokens like %0 and %1, and the node swaps them for whatever strings you feed in. One template, many prompts.
The pattern is simple and powerful. Template: a %0 portrait of a %1, dramatic lighting. input_0 = cinematic, input_1 = fox. Result: a cinematic portrait of a fox, dramatic lighting. Change the inputs, keep the template, and every run produces a coherent prompt without touching the structure. It's the string-templating workhorse for prompt roulette and batch variation workflows - usually paired with a list node that feeds each variation through.
How it works
The template string can contain up to ten tokens, %0 through %9. Each is replaced by its matching input: %0 becomes input_0, %1 becomes input_1, and so on. Any token whose input isn't connected simply becomes an empty string.
The inputs that matter:
- template (STRING, multiline) - your prompt skeleton with
%0…%9placeholders. - token_count (INT, 1–10, default 1) - controls how many input slots the UI shows. It's a UI affordance, not a hard limit on replacement.
- input_0 (STRING, required) through input_9 (STRING, optional) - the values that fill the tokens.
The output is result - the fully assembled string, ready for your CLIP Text Encode or wherever prompts go.
Installing it
Token Replace comes from ComfyUI-TinyBee, a small MIT-licensed utility pack with no model downloads. Via Manager:
- ComfyUI Manager → Custom Nodes Manager.
- Search "ComfyUI-TinyBee" and install.
- Restart ComfyUI.
Or clone:
cd ComfyUI/custom_nodes
git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
Restart and it's under 🐝TinyBee/Strings. No extra dependencies beyond what ComfyUI ships - jsonata in the pack's requirements is only for its JSON Parser node.
Gotchas
token_count is cosmetic: the replacement engine always tries all ten tokens, so if a template accidentally contains %7 but no input_7 is connected, that token quietly vanishes into an empty string - easy to miss and confusing when the prompt looks wrong. Also the token syntax is exactly %0–%9; a literal percent sign in your template is fine as long as it isn't followed by a digit you didn't mean to replace. And keep in mind the whole thing is a one-shot substitution, not a loop - if you want twenty variations from one template, feed the twenty values in from a list node rather than trying to make Token Replace iterate for you.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| template | STRING | this will replace %0 with input_0 | — |
| token_count | INT | 11–10 | — |
| input_0 | STRING | — | |
| input_1opt | STRING | — | |
| input_2opt | STRING | — | |
| input_3opt | STRING | — | |
| input_4opt | STRING | — | |
| input_5opt | STRING | — | |
| input_6opt | STRING | — | |
| input_7opt | STRING | — | |
| input_8opt | STRING | — | |
| input_9opt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | STRING | — |