Prompt Inject V2
The same trick, but now you get to pick the side
- STRING
PromptInjectV2 is the V1 node plus exactly one new switch, and that one switch is the reason to use this version instead. Where the original could only drop your injected text before a target phrase, V2 adds a boolean inject_after so you can put it on either side. That's the entire difference, and it's enough.
Quick recap of the base trick: you feed it a full prompt (text), a target phrase to anchor on, and an injection to insert - then it regex-locates the target case-insensitively and splices the injection adjacent to it, auto-handling spaces and punctuation. Defaults are the video-prompt-flavored the scene is captured and Screeching tires.. Output is a single STRING for your CLIP encoder.
The example that made V2 click for me: your base prompt is The photo shows a landscape where the scene is captured at sunset. With inject_after off, injecting with dramatic lighting gives you ...where with dramatic lighting the scene is captured at sunset. With inject_after on, you get ...where the scene is captured with dramatic lighting at sunset. Same ingredients, meaningfully different rhythm - and rhythm matters more in sentence-structured prompts than people give it credit for, because the position of a clause changes what the model treats as primary. Before-the-target tends to read as emphasis on the condition; after-the-target reads as elaboration of the scene.
Where this actually earns its keep: dynamic prompts. If the anchor phrase comes out of another node (wildcards, an LLM prompt builder, a caption loader), you can't guarantee where the text ends or what punctuation surrounds it - but you can guarantee the target phrase exists, because you control it. Injection at a known anchor is far more robust than string concatenation, and having both sides available means you can build a small "prompt surgery" pattern: inject a subject descriptor before the scene is captured and a lighting/style clause after it, from two separate V2 nodes.
The caveats are the same as V1's, plus one: matching is case-insensitive and hits only the first occurrence, so keep your target phrase unique within the prompt. And if the target isn't found, the node silently returns your text unchanged - no error, no "injection didn't land" warning. That silent-fail is the classic new-user trap; check your target string before assuming the node is broken.
Should you skip V1? Yes. V2 does everything V1 does - default inject_after = false reproduces V1's behavior exactly - so there's no reason to run the older node unless you've got an existing workflow with it baked in. Same install story as every node in this pack: ComfyUI Manager → "DJZ-Nodes", or cd ComfyUI/custom_nodes && git clone https://github.com/MushroomFleet/DJZ-Nodes && pip install -r requirements.txt. Yes, you're installing the whole 75-node pack to get a text splice. That's the DJZ bargain, and for a prompt tool this small and dependency-free it's a mildly annoying one - but it's also free, so shrug.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| target | STRING | the scene is captured | — |
| injection | STRING | Screeching tires. | — |
| inject_after | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |