Text Prefix Suffix
Assembling prompts without the ugly spacing bugs
- result_text
Text Prefix Suffix wraps a string with text on both ends - a prefix, a suffix, or both - and hands you the assembled result. In ComfyUI's text-handling world, this is the node you reach for when you're building a prompt from parts instead of typing the whole thing.
The concrete use case: you've got a base subject coming from a wildcard picker or a dropdown ("beautiful", "cyberpunk street", whatever), and you want to dress it up without hard-coding the join. Add "a" on the front and ", highly detailed" on the back, and the node does the spacing so you don't end up with "abeautiful, highly detailed" or a double space. It's also the easy way to wrap dynamic text in markers - think surrounding a filename with brackets, or tagging a prompt segment so a later node can find it. Combined with a conditional that picks prefix/suffix values, it becomes a tiny prompt-assembly station.
How it works
Straightforward string concatenation with one piece of intelligence: the add_space toggle. With it on (the default), the node inserts a single space between parts unless the prefix already ends in whitespace or the text starts with it - same check on the suffix side. So "a" + "beautiful" + "sunset" becomes "a beautiful sunset" instead of "abeautifulsunset", and you don't get double spaces when you feed in a prefix that already has a trailing space. Turn add_space off when you're deliberately gluing tokens together without a gap, like building a filename or a machine-readable string.
The inputs that matter
text- the base string. This is the thing getting dressed up.prefixandsuffix- what to add on each end. Either can be left empty, so one node covers prefix-only, suffix-only, or both.add_space- controls the connector spacing. Default on.
Only one output, result_text, a STRING you wire straight into your CLIP text encoder, a filename builder, or anywhere else the combined text is going.
Installation
Grab the whole pack through ComfyUI Manager (search "DebugPadawan's ComfyUI Essentials"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials.git
Restart ComfyUI after cloning. No models to download, no heavy dependencies - this node is pure string work and needs nothing beyond the Python that ComfyUI already runs. (The pack's requirements.txt lists numpy/torch/opencv for its image and math nodes; irrelevant here.)
Gotchas
The one thing that trips people up is forgetting add_space exists and assuming the output will look clean. If you leave it on but your text already ends with a newline from a multiline field, the node is smart enough not to double up - but the newline stays, and a stray newline in the middle of a prompt is a classic subtle bug. If your assembled text looks wrong, check whether the base string is carrying invisible whitespace rather than blaming the node.
Also worth knowing: this is a from-scratch utility in a small pack with essentially no community footprint - it's not a famous node, and there aren't threads full of people debugging it. If the output surprises you, test the node in isolation with a plain string first. It's one of those "of course it works, so when it doesn't, it's the input" situations.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | beautiful | — |
| prefixopt | STRING | — | |
| suffixopt | STRING | — | |
| add_spaceopt | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result_text | STRING | — |