๐ Substring Extractor
When your LLM writes a whole prompt, this pulls out just the part you need
- STRING
If you've started leaning on an LLM to write your prompts - and plenty of people have, feeding Gemini or Claude a rough description and getting back a structured multi-line block in return - you've hit this wall: the model gives you one big string with Begin Face;, Begin Eyes;, Begin Clothing; sections, but your workflow only wants one of them. You want the eyes section for one conditioning pass and the clothing section for another, or to trigger a LoRA only when the right part shows up. Substring Extractor is the two-second answer: it takes a long text, a start marker, and an end marker, and hands back just the chunk between them.
It's the smallest kind of custom node there is - a single function with zero dependencies. No Python packages, no model downloads, nothing to babysit. The whole thing is about 35 lines, which is also worth knowing for another reason: ComfyUI custom nodes run arbitrary code on your machine with no sandbox (the ecosystem has been burned by this before), so a node this small and this readable is exactly what you want to see. You can read every line in a minute.
How it works
Under the hood it's doing a plain Python str.find() - no regex, no fuzzy matching. It locates your begin_delimiter in the text, then finds the first end_delimiter after it, slices between the two, and .strip()s the result so you don't get a stray newline gumming up your conditioning. The defaults are Begin Eyes; and End Eyes;, so out of the box it's ready for the common "one section per region" LLM prompt format. Paste your LLM output in, set the delimiters for the section you care about, and out comes exactly that section.
The inputs that matter
There are three inputs, all required, and they're all plain text - this node genuinely needs nothing else:
- text - the big LLM-generated string you want to carve up (multiline).
- begin_delimiter - where to start cutting. Default
Begin Eyes;. - end_delimiter - where to stop. Default
End Eyes;.
The single output is a STRING, which wires straight into a CLIP Text Encode node for conditioning, into a text-concat or prompt-builder node, or into whatever LoRA-trigger logic you've rigged up. Since it's just text, the output works anywhere a string input works.
Where people get burned
Two traps, both real. First, the delimiters are matched exactly, case-sensitive - begin eyes; will not find Begin Eyes;, and if your LLM drifts in formatting, you get nothing. Second, and sneakier: when a delimiter isn't found, the node doesn't error out. It returns a literal string like Start delimiter not found as its output. That string then flows downstream as if it were real prompt text, so a silent miss turns into a quietly garbage conditioning pass instead of a loud failure. If a section keeps coming out empty or your images suddenly get weird, check the node's output value before anything else - it's probably telling you the marker is missing.
Installing it
Standard custom node install. Easiest route is ComfyUI Manager - search for ComfyUI-SubstringExtractor and install it. Or from the terminal:
cd ComfyUI/custom_nodes
git clone https://github.com/kplkasteel/ComfyUI-SubstringExtractor
Then restart ComfyUI. That's the whole install - there's no requirements.txt, no heavy dependency lurking in the clone, no model files to place. It'll show up as ๐ Substring Extractor under TextParsing in the node menu.
Is it a node you'll build a workflow around? No. It's a tiny utility that earns its place once you start automating prompt generation - the kind of thing that sits in a corner of a graph and quietly saves you from hand-slicing LLM output into conditioning passes.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | โ | |
| begin_delimiter | STRING | Begin Eyes; | โ |
| end_delimiter | STRING | End Eyes; | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | โ |