String Conditional Append
Keep your prompt's keywords honest, without duplicates
- output_string
- was_appended
If you've ever had a quality-tag or style keyword vanish from a prompt because an LLM rewrote it, or balloon into three copies because a wildcard process added it twice, you know the exact problem this node exists for. String Conditional Append looks at your text, checks whether a list of strings is already present, and adds only the ones that are missing. It's a de-duplicator with an opinion, and it's genuinely one of the smarter small nodes in this pack.
The classic use is a guaranteed-words tail. Say you feed an LLM-generated prompt into the sampler but never want it to lose masterpiece, best quality or a style token. You list those strings one per line, wire the prompt in, and get back a prompt that provably contains them - once. The "only if missing" bit is the whole point; a dumb append would stack the keyword every run and wreck the prompt weighting.
How it works
The node reads strings_to_check one line at a time. For each string, it checks whether that text is already a substring of the current result (case-insensitive by default), and appends it with the configured separator only if it isn't. Missing strings are added in the order you listed them. When it's done it hands back two outputs: the modified output_string, and a was_appended boolean that's true if anything was added.
The inputs that matter
strings_to_check- one string per line. Each is checked independently, so you can protect five separate phrases in one go.position-end(default) orbeginning. Beginning is handy when the keyword is a quality anchor that should lead the prompt rather than trail it.separator- what gets inserted between text and appended strings, default", ". Change it to a space or a newline if your target syntax prefers it.match_case- off by default, soanimein your check list counts as present even if the prompt saysAnime. Flip it on if case actually matters to you.
Outputs: output_string (STRING) and was_appended (BOOLEAN). That boolean is useful - feed it into a switch or notification node to know whether the workflow just modified your text.
Installation
Zero dependencies, zero model files - this pack is plain Python. Via ComfyUI Manager: Manager > Custom Nodes Manager > search "ComfyUI_StringEssentials" > Install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/bradsec/ComfyUI_StringEssentials.git
Restart, then find it under Add Node > utils > StringEssentials.
Gotchas
- The check is substring-based, not word-based.
artin your check list matchesartistic, andphotomatchesphotorealistic. There's no whole-word toggle on this node, unlike String Strip and String Multi Replace - so if you need word-boundary matching, do that cleanup upstream with String Multi Replace instead. - One missing string appended is still
was_appended= true, even if the other four were already there. It's a "did we touch anything" flag, not a per-string report. - Appends accumulate into the same result. Each missing string is appended to the result of the previous append, so with
endposition they stack in list order. That's almost always what you want. - Case-insensitivity is the default; if a phrase exists with different casing, it's treated as present and left alone.
If your workflow ever needs "make sure these words are in the prompt" without "make sure these words are in the prompt twice", this is the node.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| input_string | STRING | The string to process | |
| strings_to_check | STRING | Enter strings to search for and append if not found (one per line) | |
| position | COMBO | end | Where to add strings if not found |
| match_case | BOOLEAN | false | Whether the search should be case-sensitive |
| separator | STRING | , | Character(s) to use between text and appended strings |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| output_string | STRING | — |
| was_appended | BOOLEAN | — |