The PromptInject node is a custom node for ComfyUI that allows you to inject additional text before a specific target phrase in your prompts. This is particularly useful for adding descriptive elements or modifiers to specific parts of your prompt without manually editing the entire text.
-
text (STRING, multiline)
- The main prompt text where you want to inject additional content
- Can be multiple lines of text
- This is your base prompt that contains the target phrase
-
target (STRING)
- The phrase where you want to inject text before
- Default value: "the scene is captured"
- Should be an exact match to what's in your text
- Case-insensitive matching
-
injection (STRING)
- The text you want to inject before the target phrase
- Default value: "Screeching tires."
- Will be automatically wrapped with spaces
- If ends with punctuation (., !, ?), will be followed by a single space
- The node takes your input text and looks for the specified target phrase
- It automatically adds appropriate spacing around your injection text
- The injection is placed immediately before the target phrase
- The result maintains proper spacing and punctuation
text: "A beautiful landscape where the scene is captured in stunning detail"
target: "the scene is captured"
injection: "during sunset"
"A beautiful landscape where during sunset the scene is captured in stunning detail"
- Choose unique target phrases to ensure precise injection
- Make sure your target phrase exists in the text exactly as written
- The injection will maintain proper spacing, so you don't need to add extra spaces
- Punctuation at the end of your injection will be handled automatically
- The node uses regular expressions for text matching and replacement
- Matching is case-insensitive for better flexibility
- Automatic space handling ensures clean text integration
- Logging is implemented for debugging purposes
The node returns a single STRING containing the modified prompt with the injected text.