EBU PromptHelper Truncate
Cut a prompt at a marker — the LLM-output trimmer
- modified_prompt
Truncate is the pack's surgeon: it finds the first occurrence of a substring in a prompt and deletes everything before it or after it, with a toggle for whether the marker itself gets cut too. The README frames it as "particularly useful for dynamically trimming a prompt based on a specific marker," and that's the honest use case - if an LLM or a generator hands back a prompt with a preamble, a trailing comment, or a formatting marker, this node slices it down to the part you actually want. It's one of those nodes you don't need until you need it, and then nothing else quite does the job in one node.
How it works
The mechanism is str.find() on the first occurrence, then a slice. delete_option picks the direction: "delete before" keeps everything from the marker onward, "delete after" keeps everything up to the marker. inclusive decides the marker's fate - inclusive removes it along with the deleted text, non-inclusive leaves it in the result. Four combinations cover every trimming shape:
- Delete before, inclusive:
"Hello world, welcome to the party!"withwelcome→" to the party!" - Delete before, non-inclusive →
"welcome to the party!" - Delete after, inclusive:
"The meeting will start at 3pm, please be on time."withat 3pm→"The meeting will start " - Delete after, non-inclusive →
"The meeting will start at 3pm"
The important safety behavior: if the substring isn't found at all, the node returns the prompt unchanged - no crash, no surprise truncation. It only operates on the first occurrence, so a marker appearing twice is cut at the first one.
The inputs and output
- prompt - the text to trim (multiline).
- substring - the marker to find. Exact match, case-sensitive - there's no case toggle here.
- delete_option - "delete before" or "delete after".
- inclusive - whether the marker is removed too, default true.
Output: a single modified_prompt STRING. Note it's prompt, not prompt_text - easy to misremember when you're also using the pack's Replace node.
Where it fits
Three patterns. (1) LLM-output cleaning: local LLM prompt-builders often wrap answers in "Here is your prompt:" preambles or trailing reasoning - Truncate at the marker that separates the actual prompt and keeps only the useful part. (2) Template slicing: if a shared template file has a header you never want in the final prompt, delete-before at the header's end marker. (3) Safety trim: delete-after at a marker that ends the meaningful prompt, in case an upstream generator appends stuff you don't want encoded. Because it's deterministic and one node, it slots into the same pipeline as the pack's Replace and Randomize without adding state.
Install
Part of EBU PromptHelper. ComfyUI Manager: search "EBU PromptHelper", or:
cd ComfyUI/custom_nodes
git clone https://github.com/burnsbert/ComfyUI-EBU-PromptHelper
then restart ComfyUI. No models, no extra dependencies - standard library only.
Troubleshooting
The two gotchas are both "it did exactly what you said." First, the substring is exact and case-sensitive, so "Welcome" won't match "welcome" - if your marker case varies, you'll get the pass-through (unchanged) result, which looks like a no-op. Second, inclusive defaults to true, and its effect is subtle: with delete-before, inclusive leaves a leading space after the cut (see the example - " to the party!"), so if you're feeding the result into a prompt you may want non-inclusive, or accept the stray space. Neither is a crash - just check the mode before you assume the node misbehaved.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| substring | STRING | — | |
| delete_option | COMBO | delete before | 2 options: delete before, delete after |
| inclusive | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| modified_prompt | STRING | — |