ComfyUI - RE-CustomUtils
A collection of custom nodes for ComfyUI.
Note
This project was inspired by the cookiecutter template, though the full architecture is a bit different.
Quickstart
- Install ComfyUI.
- Install ComfyUI-Manager
- Look up this extension in ComfyUI-Manager. If you are installing manually, clone this repository under
ComfyUI/custom_nodes. - Restart ComfyUI.
Features
PromptPresetSelector node
Inputs
syntax(str), default to{% | %}— defines the opening tag, separator, and closing tag as a single field, space-separatedpreset_index(int), 0-based, default to0— loops both ways within rangepreset_name(combo) — dynamic dropdown, active whenpreset_namesis filledpreset_names(str), optional — comma-separated list of preset names. Ex:neutral, happy, sad. If fewer names than presets, remaining are auto-named (preset_2,preset_3...). If more, extra names are ignored.text(str), multiline textarea supporting preset blockscleanup(bool), default toTrue
Outputs
text(str) — the formatted text, with preset blocks resolvedpreset_index(int) — the selected indexpreset_count(int) — the number of presets found across blocks
Usage
Include preset blocks in your text using the syntax defined in the syntax field. Each block holds options separated by the separator. Depending on preset_index, the matching option is injected and the block markers are removed.
This is {% an example | a text | another text %} for {% the PromptPresetSelector | the README | %}
preset_index=0->This is an example for the PromptPresetSelectorpreset_index=1->This is a text for the READMEpreset_index=2->This is another text for
Empty presets are allowed — the block is simply replaced by an empty string.
Custom syntax
The syntax field allows changing the opening tag, separator and closing tag. Format is always open_tag separator close_tag, space-separated.
<< / >>
Would match blocks like << option_a / option_b >>.
Preset names
When preset_names is filled, preset_index is replaced by a dynamic dropdown (preset_name) built from the comma-separated names. The dropdown resets to the first preset when activated.
If fewer names than presets are defined, remaining entries are auto-named (preset_2, preset_3...). If more names than presets, extra names are ignored.
Preset references
Inside a preset, you can reference a previously declared preset using $N (0-based index).
{% base style | $0, hat | $1, jewelry %}
preset_index=0→base stylepreset_index=1→base style, hatpreset_index=2→base style, hat, jewelry
References are resolved recursively — $1 in preset 2 resolves preset 1, which may itself reference preset 0.
Rules:
$Ncan only reference a preset with a lower index (forward references are not allowed)$Nmust be within range- Circular references raise an error
Validation
The node runs the following checks and stops the workflow on error:
syntaxmust contain exactly 3 space-separated partsopen_tagandclose_tagmust be different- All preset blocks in
textmust have the same number of options preset_indexmust be within range
Cleanup
When cleanup is enabled, the following are removed from the output:
- Spaces before commas
- Double or empty commas
- Empty lines
Web
PromptPresetSelector editor
The text widget is replaced by a contentEditable div that provides
syntax highlighting:
- Tags and separators are highlighted in orange
- The active preset is shown in full brightness
- Inactive presets are grayed out
$Nreferences are highlighted in blue on the active preset- Colors update in real time while editing
- Pasting always inserts plain text, stripping any HTML formatting
- Highlighting updates live when
syntax,preset_indexorpreset_nameare changed
When preset_names is filled, and preset_name replaces preset_index, the dropdown
resets to the first preset when activated.
Keyboard shortcuts
| Shortcut | Action |
|---|---|
Ctrl+Up |
Increase weight of selected text or word under caret by 0.1. Ex: tag → (tag:1.1) |
Ctrl+Down |
Decrease weight of selected text or word under caret by 0.1. Ex: (tag:1.1) → tag when reaching 1.0 |
The selection is preserved after each keypress, consistent with ComfyUI native behavior.
TODO
- Add a field to easily concatenate text at the end of the output
- Wildcard mode for presets (randomly selected, index to -1 or -2?)
