RedNode Prompt Converter
A caption converter that swaps her→his without mangling 'there'
- text
RedNode Prompt Converter exists for the caption job that every LoRA trainer eventually hits: your source captions say "a woman", your subject is a man, and hand-editing a few thousand caption files is soul-destroying. This node swaps gender words at the word boundary - her→him and his→hers - without touching the her inside "there". That last part is the whole trick, and it's why a naive find-and-replace is a trap you should never use on prompts.
It's built on word-boundary matching, which is the difference between correct and catastrophic. A regex \bher\b-style match sees the word boundary, so "there" and "herself" pass through untouched. The swaps are also case-preserving - "Her" becomes "Him" with the capital intact - which keeps caption grammar sane. The brief describes it as the Neo JoyCaption helper tables, so it's aimed squarely at the caption-generation ecosystem where a gender flip on a batch is the recurring chore.
What it converts
gender_swap- off, male-to-female, female-to-male. Whole words only, case-preserving.style_convert- off, or convert medium/style vocabulary between realistic photography and anime terms. This is the interesting one if you train across styles: it turns "photograph" into "anime illustration", "cel shading" into "skin texture", "1girl" into "a woman", and repairs a/an as it goes ("a illustration" → "an illustration").custom_rules- your own lines inword => replacementform, applied last, whole-word and case-preserving,#for comments. Extending the tables with your own vocabulary is the intended workflow:
prince => princess
king => queen
The authority lock
The two most useful inputs for serious caption pipelines are style_authority and lock_to_authority. Wire the Studio Workspace's moodboard_prompt into style_authority, turn the lock on, and any style or medium words the passing text uses that the authority doesn't get stripped - so a photo caption can no longer fight an anime moodboard. lock_lighting is the stronger version that also strips lighting and atmosphere vocabulary (golden hour, bokeh, backlighting) unless the authority uses them. This is prompt text being treated as data with a declared owner, and it's the single most "wait, that's clever" part of the node.
There's also an NSFW block - nsfw_act_swap, nsfw_remove_cum, nsfw_shave_pubic - clearly labelled as such, doing the corresponding caption rewrites for datasets that need them.
The single output, text, is the converted string, ready to wire anywhere.
Installing it
git clone https://github.com/RedNodeAI/ComfyUI-RedNodeStudio.git ComfyUI/custom_nodes/ComfyUI-RedNodeStudio
Restart ComfyUI, or use ComfyUI Manager (search RedNode Studio). No pip deps, no models. Python 3.10+.
The gotcha
Whole-word matching is correct, but it's also literal: it won't fix "man" inside "woman", and it won't catch every gendered noun ("actress", "king") unless a table or your custom rule covers it. Check one converted caption by eye before you batch the whole dataset - the same advice you'd follow for any bulk transform, and it takes one read of one file.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | Caption/prompt to convert. Wire a captioner (Florence2, JoyCaption, WD tagger) or any string output here. | |
| gender_swap | COMBO | off | Swap gender words (whole words only, case-preserving, so 'her' never matches inside 'there'). e.g. male to female. |
| style_convert | COMBO | off | Convert medium/style vocabulary between realistic photography and anime terms (photograph vs anime illustration, cel shading vs skin texture, 1girl to a woman, and so on). Whole-word, case-preserving, a/an repaired. Extend it with custom_rules. |
| nsfw_act_swapopt | COMBO | off | NSFW. Rewrite vaginal / intercourse / penetration terms to the chosen act (oral or anal). |
| nsfw_remove_cumopt | BOOLEAN | false | NSFW. Remove cum / ejaculation / semen / sperm terms; leftover commas and spaces are tidied. |
| nsfw_shave_pubicopt | BOOLEAN | false | NSFW. Rewrite pubic-hair mentions to 'no pubic hair, shaved pubic hair'. |
| custom_rulesopt | STRING | Your own rules, one per line: word => replacement (applied last, whole-word, case-preserving; '#' starts a comment). Example: prince => princess king => queen | |
| lock_to_authorityopt | BOOLEAN | true | When style_authority is wired, strip style and medium words this text uses that the authority does not. Wire the workspace's moodboard_prompt in and a photo caption can no longer fight an anime moodboard. |
| style_authorityopt | STRING | The prompt that OWNS the style, usually the workspace's moodboard_prompt output. Style words in the passing text that this authority does not itself use are removed. | |
| lock_lightingopt | BOOLEAN | false | Stronger authority lock: also strip lighting and atmosphere vocabulary (golden hour, bokeh, backlighting, long shadows) the authority does not use. Lighting words the authority mentions survive. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |