Extensions/slarti-prompt
ComfyUI Extension

slarti-prompt

Prompt builder node: part_1 and part_2 with up to 10 inserts before, between and after them, joined into one STRING. Built-in {a|b|c} choices and __name__ wildcard files stored in the ComfyUI user folder.

By Slartibart23·Created about 24 hours ago·Updated about 24 hours ago· 0
Slartibart23/slarti-prompt
Nodes—
On cloudLocal install
Stars0
Updatedabout 24 hours ago
Readme

slarti-prompt

A simple prompt builder node for ComfyUI.

Write your prompt in two fixed parts, part_1 and part_2, and add inserts in three places: before part_1, between the two parts and after part_2 (0–10 inserts each). The node joins everything into one STRING. Swap small details such as glasses, hair color or clothing in the inserts without touching the rest of the prompt.

The output is a plain STRING, so it can go anywhere: CLIP Text Encode, an LLM / Grok prompt node, a text display, a filename and so on.

Built-in wildcards: {option1|option2|option3} choices and __name__ wildcard files. No other custom node packs needed.


The node

| Widget / input | Type | Description | |---|---|---| | inserts_before | dropdown 0–10 (default 0) | Number of insert fields before part_1: before_1 … before_10. | | part_1 | STRING (multiline) | First part of the prompt. | | inserts_middle | dropdown 0–10 (default 1) | Number of insert fields between part_1 and part_2: middle_1 … middle_10. | | part_2 | STRING (multiline) | Second part of the prompt. | | inserts_after | dropdown 0–10 (default 0) | Number of insert fields after part_2: after_1 … after_10. | | wildcards | toggle on / off | Resolve wildcards. When off, the text is passed through unchanged and the seed is hidden and frozen. | | seed | INT (only visible when wildcards is on) | Seed for the wildcard choices. Use fixed to keep a result, randomize for a new variant on every run. |

| Output | Type | Description | |---|---|---| | positive | STRING | The assembled prompt. |

Insert fields have a light blue background, so you can tell them apart from part_1 and part_2 at a glance.

Every text field can take an optional link: drag a STRING connection onto the field and the field uses the linked text instead of what you typed.

How the parts are joined

Parts are joined in this order, separated by a blank line:

before_1 … before_n
part_1
middle_1 … middle_n
part_2
after_1 … after_n

Empty fields are skipped, so you never get stray blank lines.

before_1:  photorealistic
part_1:    Portrait of a woman in a cafe
middle_1:  wearing glasses
middle_2:  blonde hair
part_2:    soft window light, 85mm
after_1:   film grain

Output:

photorealistic

Portrait of a woman in a cafe

wearing glasses

blonde hair

soft window light, 85mm

film grain

Wildcards

Wildcards work in every field (part_1, part_2 and all inserts) and can be used as often as you like.

Choices: {a|b|c}

One of the options is picked at random.

{brown hair|blonde hair|red hair}

→ brown hair, blonde hair or red hair

Nested choices

Choices can be nested to any depth.

{red|{dark|light} blue} dress

→ red dress, dark blue dress or light blue dress

Empty option: "sometimes nothing"

Leave an option empty to sometimes output nothing.

woman, {wearing glasses|}, soft light

→ woman, wearing glasses, soft light or woman, soft light

When an empty option is picked, the comma next to it is removed as well, so you never get leftovers like woman, , soft light or a trailing dress,. Double spaces are cleaned up too.

Tip: repeat an option to make it more likely. {glasses|glasses|} gives glasses about two times out of three.

Wildcard files: __name__

__name__ picks a random line from the text file name.txt in the wildcard folder:

ComfyUI/user/slarti-prompt/wildcards/

The folder lives in ComfyUI's user folder, so your wildcard files survive node updates and reinstalls. It is created on first start, together with an example file haircolor.txt.

Example haircolor.txt:

# lines starting with # are comments, empty lines are ignored
brown hair
blonde hair
red hair
{short|long} silver hair

Use it in a prompt:

Portrait of a woman, __haircolor__, soft light
  • Subfolders: __clothes/dresses__ reads wildcards/clothes/dresses.txt.
  • Lines in a wildcard file can contain {a|b} choices and other __name__ wildcards.
  • Files are read as UTF-8.
  • A wildcard whose file is missing stays in the text unchanged, and a warning is written to the ComfyUI console.
  • After you edit a wildcard file, the node runs again automatically on the next queue.

Seed

All choices depend on the seed:

  • Same seed + same text = same result. Set control after generate to fixed to keep a prompt you like.
  • Set it to randomize to get a new combination on every run.
  • Each field has its own random sequence. Editing middle_2 does not change the choices in part_1.

Braces without | stay as they are

{ … } without a | inside is treated as normal text. JSON or other text that uses braces passes through safely:

{"style": "photo", "hair": "{brown|blonde}"}

→ {"style": "photo", "hair": "blonde"}

Escaping

To output {, } or | literally inside a choice, write \{, \} or \|.

Turning wildcards off

Set wildcards to off to pass every field through unchanged, braces and __name__ included.

When wildcards is off:

  • the seed widget and its control after generate are hidden,
  • control after generate is set to fixed, so no new seed is ever generated,
  • the node does not re-run on its own, and nothing downstream re-runs because of it.

Use this when you want to keep working on the same image with exactly the same prompt. When you switch wildcards back on, the seed reappears with its previous control after generate mode (for example randomize).

Changing the number of inserts keeps the text you already typed. If you go from 3 inserts down to 1 and back up to 3, inserts 2 and 3 come back with their text while the workflow is open.


Installation

ComfyUI Manager / Registry

Search for slarti-prompt in the ComfyUI Manager.

Manual

cd ComfyUI/custom_nodes
git clone https://github.com/Slartibart23/slarti-prompt

Restart ComfyUI. The node is under slarti → slarti-prompt, or search for slarti-prompt.

No extra Python dependencies.

Requirements

A recent ComfyUI with V3 node API support for dynamic inputs (DynamicCombo). Tested with ComfyUI 0.41.2 and frontend 1.55.17.


License

MIT