Nodes/cgem156-ComfyUI๐ŸŒ/Prefix String ๐ŸŒ
ComfyUI Node

Prefix String ๐ŸŒ

Add the same text to the front of every prompt in a batch

By laksjdjfยทCreated 2 years agoยทUpdated about a month agoยท 93
Prefix String ๐ŸŒ
  • prompts
  • BATCH_STRING
โ—„prefixโ€”โ–บ

A small, single-purpose node in cgem156's batch_condition family: it takes a batch of prompt strings and a fixed prefix, and returns the same batch with that prefix stuck on the front of every single entry. Instead of editing ten prompt variants one by one to add "masterpiece, best quality, " (or any other shared boilerplate) to each, you add it once here.

How it fits the pack

This is a transform step, not a source or a sink - it expects a BATCH_STRING already built by something like BatchString or RandomColorPrompt, modifies it, and hands a BATCH_STRING back out. That means it composes: you can chain more than one of these (or mix in other batch transforms) before finally sending the result into CLIPTextEncodeBatch for encoding.

Inputs and outputs that matter

  • prefix - the text to prepend, multiline, applied identically to every entry in the batch.
  • prompts - the BATCH_STRING to modify.
  • Output: BATCH_STRING - same batch size as the input, each entry now starting with your prefix text.

Installing it

ComfyUI Manager โ†’ search cgem156-ComfyUI๐ŸŒ โ†’ install โ†’ restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/laksjdjf/cgem156-ComfyUI

then restart ComfyUI. Nothing extra to download for this node.

Common issues & troubleshooting

Won't accept a plain string for prompts. This node expects the pack's BATCH_STRING type, not a single string - you need BatchString, RandomColorPrompt, or another node producing a batch upstream. If you only have one prompt, wrap it through BatchString as a batch of one rather than trying to feed it in directly.

Missing space or punctuation between prefix and prompt. The node concatenates exactly what you typed - if you want "masterpiece, best quality, [your prompt]" rather than "masterpiece, best quality[your prompt]" jammed together, make sure your prefix text itself ends with the separator (a comma and space, typically) you want.

Wrong node for a suffix. This only prepends. If you want text added to the end of each prompt instead of the front, this isn't the tool - you'd need to either bake it into your base prompt before this step or look for a different node if the pack has a suffix equivalent.

Batch size mismatch downstream. The output batch size always matches the input batch size - if something downstream expects a specific count, check what came out of the node that built your original BATCH_STRING, not this one; PrefixString doesn't add or remove entries, only text.

Categorycgem156 ๐ŸŒ/batch_condition

Inputs (2)

NameTypeDefaultDescription
prefixSTRINGโ€”
promptsBATCH_STRINGโ€”

Outputs (1)

NameTypeDescription
BATCH_STRINGBATCH_STRINGโ€”