😺NKD Prompt Variables
Variable chips that turn a prompt into a batch
- variables
- prompt
The grind every batch-prompter knows: you want twelve versions of the same prompt - same scene, same lighting, twelve different subjects, or twelve locations swapped into one sentence. So you either copy the prompt twelve times into a row of CLIP Text Encode nodes, or you hand-edit and re-run over and over. 😺NKD Prompt Variables is the version where you write the prompt once, drop variable chips into it, and feed each chip from a socket. Change the input, the prompt changes. Wire a list into a chip and the prompt resolves once per item - which in ComfyUI means downstream runs N times, one generation per item, no extra wiring.
How it works
The node is a prompt box with {variable_N} markers standing in for the parts that change. Say:
a portrait of {variable_1}, dramatic rim light, 35mm
then feed variable_1 a socket carrying "a tired dock worker" and that's the prompt. The variable sockets autogrow as you connect them (up to 16), and here's the nice bit: renaming a socket renames its chip in the text, and the chips drag around the box, so the whole thing stays readable instead of being a pile of obscure {variable_4} tokens. The node shows the resolved prompt right on itself, so you see what you're actually sending before you queue it.
Mechanically it leans on the engine's list behavior (the same "one input item → one execution" that all batch plumbing rides on). A plain string socket gives you one prompt; a list socket gives you one prompt per item. That's the whole trick, and it's why the node is two nodes in one.
The inputs that matter
text- the prompt itself,{variable_N}where each variable lands.variables- the autogrow sockets. Connect any STRING, or a list of strings.randomize_all(default off) - when a variable receives a list, pick one random item instead of generating one prompt per item. Shift-click an individual chip to randomize just that variable.seed- drives the random picks. Same seed, same choices, every time. It's a normal control_after_generate seed, so mind the usual "the number shown is the one that runs next" trap if you're used to that behavior from samplers.
Where it shines
Pair it with the pack's 😺NKD String Split node: have an LLM write you a list of twelve prompts or subjects, split it into a list, and feed the list into a variable. One run, twelve generations. It's equally handy for tag-heavy SDXL-lineage models where you want to sweep one token - the character, the outfit, the weather - across a batch while the base prompt stays untouched. For anything where the structure of the prompt is fixed and only the slots vary, this is the node. If you want full rewrite-every-line control instead, you don't need it.
Install
From ComfyUI Manager, search "NKD Basic Tools" and install, then restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/Nekodificador/ComfyUI-NKD-Basic-Tools
then restart. This node needs no extra Python packages, no models, nothing - it's a text utility. One honest note: the pack uses ComfyUI's newer extension API (comfy_api.latest) and the autogrow input type is on the modern side, so if the node doesn't show up, update ComfyUI before you suspect the install.
Gotchas
Forget the {variable_N} spelling and the chip never fills - it stays literal text in your prompt, which is a subtle way to silently change your generation. And randomize without a seed is reproducible-looking until it isn't: if you want the same batch back, set the seed and keep it fixed. Everything else is straightforward enough that the biggest risk is switching to it and never wanting to write twelve prompt boxes again.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | The prompt. {variable_N} marks where each variable lands. | |
| variables | COMFY_AUTOGROW_V3 | — | |
| randomize_all | BOOLEAN | false | When a variable receives a list, pick one random item instead of generating one prompt per item. Shift-click a chip in the text to randomize just that variable. |
| seed | INT | 00–18446744073709550000 | Drives the random picks — same seed, same choices. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | The resolved prompt(s). Lists on plain variables produce one prompt per item. |