Nodes/ComfyUI_TextRandomizer/🏷️ Text Random Replacer
ComfyUI Node

🏷️ Text Random Replacer

#TAG → random

By fls-eugene·Created 2 months ago·Updated 2 months ago· 0
🏷️ Text Random Replacer
    • completed_prompt
    text
    target_tag#TAG
    replacement_options
    seed1

    "🏷️ Text Random Replacer" is the tag-swapper of this pack, and it's the node you reach for when you have a prompt template you like and only want to randomize part of it. Instead of rewriting the whole prompt like the Weighted Multiline Randomizer does, you leave a #TAG placeholder in your text, list what the tag could be, and each run picks one. Same composition every time, different subject, outfit, or setting. It's a one-liner for the character-rotation trick the prompt-engineering knowledge base describes - batch a template and get the same person across different contexts with zero training.

    How it works

    Three moving parts: a template, a tag, and an option list. The text field holds your template with #TAG somewhere in it. replacement_options holds the candidates, one per line, and it reuses the pack's weighted-line engine - so cyberpunk hacker :: 2 on its own line makes that option twice as likely. The node picks one line, swaps it in for every #TAG, then expands any {a|b} brackets that survived in the result. The seed pins the whole draw, same input plus same seed equals the same completed prompt.

    One thing the code does that's easy to miss: if the tag never appears in your text, the text passes through untouched - no error, no warning. That's the silent failure to watch for. Misspelled #CHARACTER when your template says #CHARACTER is... fine, actually. But a template with no matching tag just goes through un-randomized, and if you're not looking at the output you won't notice you've been generating the same prompt for an hour.

    The inputs that matter

    • text - the template. Note this one is single-line; long paragraph prompts belong in the MultiLine sibling.
    • target_tag - the placeholder to replace, default #TAG.
    • replacement_options - one candidate per line; ::weight to bias.
    • seed - locks the pick.

    Output: completed_prompt (STRING), straight into a CLIP Text Encode or a concatenator.

    Installing it

    Same as the rest of the pack - the README is "TODO.", but there's genuinely nothing to it: no requirements.txt, no models, pure Python.

    ComfyUI Manager → Custom Nodes Manager → search "TextRandomizer" → Install → Restart
    

    or cd ComfyUI/custom_nodes && git clone https://github.com/fls-eugene/ComfyUI_TextRandomizer, then restart. That's the entire dependency story.

    Where people get burned

    The silent pass-through when the tag is missing is the big one - check your spelling. Second: this node's text is deliberately single-line, and pasting a multi-line prompt into a single-line widget quietly behaves in ways you don't want. If your template is a paragraph, use Text Random Replacer (MultiLine) instead - it's the exact same engine with a textarea. And don't forget the seed: a control_after_generate set to fixed will give you the same pick forever, which is great for debugging and infuriating when you meant to be random.

    CategoryTextRandomizer/Text

    Inputs (4)

    NameTypeDefaultDescription
    textSTRING
    target_tagSTRING#TAG
    replacement_optionsSTRING
    seedINT10–18446744073709550000

    Outputs (1)

    NameTypeDescription
    completed_promptSTRING