Formatting and Concatenating Strings
Build a prompt or metadata string with optional parts that cleanly drop out
- FormattedString
Formatting and Concatenating Strings is the pack's workhorse: three string slots, each made of a pre, body, and post part, all joined in order by a separator you choose. It reads like a clunky UI, but it exists to solve a real problem - building one long string out of pieces that may or may not be filled in, without ending up with a mess of dangling separators.
The classic case is a prompt assembled from conditionals: a quality-string prefix from a selector, a LoRA-trigger tag in the middle, a style tag at the end. If any piece is empty, you don't want its neighbors' glue left behind. This node handles that for you.
How it works
Each of the three slots - A, B, C - has three inputs: A_Pre_string, A_Body_string, A_Post_string, and the same for B and C. The logic per slot is simple and worth knowing precisely:
- The slot is included only if its body is non-empty.
- If included, it contributes
pre + body + postas one chunk. - Chunks are joined with the single required input, separator (default: a space).
So an empty A_Body_string means A's pre and post text vanish too, and the separator doesn't double up. That's the whole "optional parts that cleanly drop out" promise - it's the difference between "cat,,, fluffy" and "cat, fluffy".
The single output is FormattedString (a STRING), which is marked as an output node, so it runs even if nothing downstream consumes it - handy when you're still building the graph.
What beginners actually set
- separator - pick once and forget. A space for prompts,
,for tag lists,\nif your saver wants line-separated metadata. This is the one required input. - BODY strings - the live, dynamic part. This is where a LoRA name from Lora Selector, a wildcard expansion, or a caption goes.
- PRE / POST strings - the fixed framing. For metadata you'll often write
"Loras: "as a pre and nothing as a post; for prompts it's<lora:and:0.8>.
Since the three slots are independent, you can use one slot for your quality tags, one for character, one for style, and each stays optional.
Installing it
Part of the ComfyUI-StringsAndThings pack. ComfyUI Manager: search "ComfyUI-StringsAndThings" → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/PressWagon/ComfyUI-StringsAndThings
No model downloads. Heavy dependencies are none beyond what ComfyUI already ships (scipy is in the requirements but only the Fourier node touches it; the pinned torch/numpy versions are normally already satisfied).
Caveats
- Not batch-aware, like the rest of the pack. It's one string in, one string out per run.
- All inputs are single-line (
multiline: false). You can't paste a long multi-line block into a slot and expect the UI to keep it pretty - long metadata is fine, but it'll be one line. - Pre/post text is only dropped when the body is empty. If your body is genuinely " " (a space, not empty), the slot counts as filled. When a slot refuses to disappear, that's the usual culprit.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| separator | STRING | — | |
| A_Pre_stringopt | STRING | — | |
| A_Body_stringopt | STRING | — | |
| A_Post_stringopt | STRING | — | |
| B_Pre_stringopt | STRING | — | |
| B_Body_stringopt | STRING | — | |
| B_Post_stringopt | STRING | — | |
| C_Pre_stringopt | STRING | — | |
| C_Body_stringopt | STRING | — | |
| C_Post_stringopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| FormattedString | STRING | — |