Nodes/ComfyUI Image Saver/Random Character Picker (Image Saver)
ComfyUI Node Runs on cloud

Random Character Picker (Image Saver)

Roll random danbooru-style character tags into a prompt

By alexopus·Created 3 years ago·Updated 29 days ago· 191
Random Character Picker (Image Saver)
    • tags
    file_path
    count1
    delimiter,
    replace_underscoretrue
    escape_parenstrue
    trailing_commafalse
    weight_by_countfalse
    seed0
    include_core_tagsfalse
    include_copyrightfalse
    exclude
    filter

    This is the odd one out in the Image Saver pack - nothing to do with saving files. It reads a text file of character tags and randomly picks some to drop into your prompt. If you generate anime/booru-style images and want variety without hand-picking a character every run, this rolls the dice for you: point it at a tag list, tell it how many to grab, and it outputs a formatted tag string ready to feed a text encoder.

    Think of it as a lightweight wildcard specifically shaped for danbooru-style character tags, with the formatting knobs those tags actually need.

    How it works

    You give it a file_path to a tag file and it selects count entries at random (the seed makes that repeatable). Then it formats them the way prompt tags want: replace_underscore turns character_name into character name, escape_parens backslash-escapes parentheses so they don't get read as prompt-weighting syntax, and delimiter sets what goes between tags. weight_by_count biases the random pick toward more common tags rather than treating every entry equally, and exclude / filter let you blocklist or narrow the pool. The include_core_tags and include_copyright toggles pull in the character's associated defining tags and source series when your file carries them.

    The inputs and outputs that matter

    • file_path - the tag file to draw from. This is the one you have to get right; no file, nothing to pick.
    • count - how many characters to grab (1–1000).
    • seed - fix it for reproducible picks, vary it for fresh ones.
    • replace_underscore / escape_parens - leave both on for normal prompt use; they make the tags actually parse correctly.
    • weight_by_count / filter / exclude - shape the pool and the odds.

    The single output is tags (a STRING) - wire it into a CLIP Text Encode, or concatenate it with your base prompt.

    Installing it

    ComfyUI Manager: search ComfyUI Image Saver, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/alexopus/ComfyUI-Image-Saver
    cd ComfyUI-Image-Saver
    pip install -r requirements.txt
    

    Restart, hard-refresh. The pack ships no tag file for you - you supply your own.

    Where people get tripped up

    The whole thing hinges on the file. Point file_path at a list that doesn't exist, or one in a format the node doesn't expect, and you get nothing useful - this is where most confusion starts, so confirm the path and that the file is a plain tag list. The include_core_tags / include_copyright toggles also only do something if your file actually carries that structured data; on a flat list of names they're inert.

    And match your formatting to your model. replace_underscore and escape_parens are on by default because booru-trained SD 1.5 / SDXL checkpoints expect spaced, escaped tags - but if you're feeding a natural-language model, a pile of comma-separated danbooru tags isn't how it wants to be prompted. This is a tool for tag-based checkpoints; on newer LLM-encoder models it's the wrong shape of input.

    Categoryutils

    Inputs (12)

    NameTypeDefaultDescription
    file_pathSTRINGpath to a CSV file with character, trigger, core_tags, copyright, and count columns
    countINT11–1000number of characters to pick
    delimiterSTRING, string used to join all output tags
    replace_underscoreBOOLEANtruereplace underscores with spaces in output
    escape_parensBOOLEANtrueescape ( and ) as \( and \) to prevent ComfyUI from interpreting them as attention weights
    trailing_commaBOOLEANfalseappend a trailing comma to the result
    weight_by_countBOOLEANfalseuse the count column as sampling weight — characters with more posts are more likely to be picked
    seedINT00–18446744073709550000random seed — same seed produces the same selection
    include_core_tagsBOOLEANfalseappend each character's core descriptive tags (e.g. hair color, eye color) after their trigger
    include_copyrightBOOLEANfalseappend each character's copyright/series name after their tags
    excludeSTRINGcomma-separated character names to exclude from the pool before sampling (case-insensitive, underscores and spaces are equivalent)
    filterSTRINGonly consider characters whose name contains this substring (case-insensitive); leave empty for no filtering

    Outputs (1)

    NameTypeDescription
    tagsSTRING