AutopromptProcessor (CRT)
Sanitize autogenerated prompts before they wreck your render
- processed_text
A lot of modern workflows pipe a prompt out of an LLM or an "autoprompt" helper and straight into the sampler. Which is great, until the model spits out phrasing your checkpoint has never seen, or a word that trips over your LoRA's trigger, or the same token appearing in three different forms. AutopromptProcessor sits between that text source and your text encoder and cleans house: it applies a list of word replacements and optionally prefixes a trigger word, then hands you a tidy STRING to encode.
The pitch is boring and that's the point. It's prompt hygiene as a reusable node instead of a regex you wrote once in a text editor and lost.
How it works
Three inputs, one pass of work:
- autoprompt (
STRING) - the raw text to process. - replacements - one rule per line in
old_word|new_wordformat. Lines starting with#are treated as comments and skipped. Replacement is whole-word and case-insensitive, sodark|moodychangesdarkbut notdarkness, and catchesDarktoo. That whole-word behavior is deliberate - you don't wantold|newmangling every word that merely contains the target. - custom_prefix - text prepended to the result. This is the field designed for LoRA trigger words:
add_detail, masterpiecein front of whatever came in.
Output is processed_text (STRING), ready for a CLIP Text Encode.
Order of operations: replacements run first, then the prefix is joined on. Empty prefix is skipped entirely, and if the processed text ends up empty the prefix alone comes out.
A practical example
Say your autoprompt helper writes "a photo of a woman with long brown hair, cinematic lighting". Your model is fine with that, but your style LoRA responds to a specific trigger and your checkpoint hates the word "photo". Set replacements to:
photo|portrait
woman|girl
and custom_prefix to lora_trigger_token,. Result: lora_trigger_token, a portrait of a girl with long brown hair, cinematic lighting. Took three seconds and now every run is consistent.
Installing it
CRT-Nodes again - ComfyUI Manager → CRT-Nodes, or clone + pip install -r requirements.txt, restart, and it lives under CRT/Text. No model downloads, no extra dependencies; it's pure string work.
Where people get burned
The replacement format is old|new with the pipe as separator, and there's no escaping - if your old or new text contains a | it'll split wrong. Keep rules to single tokens and it's fine. Also note it processes the text as one blob: no comma-splitting, no weighting. It replaces and prefixes, that's all. If you need per-segment rewriting or dynamic scheduling, you want the pack's Dynamic Prompt Scheduler instead - this node is the simple hammer.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| autoprompt | STRING | Connect a string input containing the autoprompt text to process | |
| custom_prefix | STRING | Custom Prompt Prefix / LoRA TriggerWord: Text to add before the processed autoprompt. Leave empty to skip prefix. | |
| replacements | STRING | old_word|new_word another_word|replacement | Word replacements, one per line using format: old_word|new_word |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| processed_text | STRING | — |