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

Random Tag Picker (Image Saver)

Shuffle random tags into your prompt

By alexopus·Created 3 years ago·Updated 29 days ago· 191
Random Tag Picker (Image Saver)
    • tags
    file_path
    count5
    delimiter,
    replace_underscorefalse
    escape_parenstrue
    trailing_commafalse
    weight_by_countfalse
    seed0
    exclude
    filter

    The general-purpose sibling of the Random Artist Picker. Same idea - pull random entries from a text file and format them into a prompt fragment - but aimed at any kind of tag, not just artists. Keep a file of poses, outfits, lighting, settings, whatever, and let this node roll a handful into your prompt each run. It's how you generate variety at scale without hand-editing the prompt every time.

    This plays naturally with Danbooru-style tag prompting, where the vocabulary is standardized labels rather than sentences: 1girl, long hair, dutch angle, looking at viewer. On Illustrious, NoobAI and other Danbooru-trained models, a correct tag beats a description for controlling pose, clothing and camera. Feed this node a curated tag file and you get controlled randomness - the model still understands every tag, but you're not the one deciding which ones fire.

    How it works

    You point it at a text file, tell it how many tags to grab, and it randomly selects and formats them. The defaults differ slightly from the artist picker in ways that make sense for general tags: it grabs 5 by default (versus 1), and replace_underscore defaults to false - because a lot of booru general tags are meant to keep their underscores. Otherwise the machinery is identical.

    The inputs and outputs

    What you'll actually set:

    • file_path - the text file of tags to draw from. One entry per line. This is required and does nothing useful empty.
    • count (default 5) - how many tags per roll. More tags, more chaos.
    • seed - the random draw. Fix it to reproduce a result, randomize it to keep rolling.

    The formatting options:

    • replace_underscore (default false) - swap underscores for spaces. Off by default here; flip it on if your model prefers spaced tags.
    • escape_parens (default true) - escape parentheses so they aren't misread as attention-weighting syntax.
    • delimiter (default , ) - separator between picks.
    • weight_by_count - bias the draw toward more-frequent tags if your file has counts.
    • exclude and filter - trim the pool: drop tags you never want, or keep only matches.
    • trailing_comma (default false) - leave a comma on the end for clean concatenation onto a base prompt.

    One output: tags (STRING) - the formatted tag string, ready for your text encode or a concat node.

    How to install it

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

    Manually:

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

    then restart. No downloads - you bring your own tag file.

    Common issues & troubleshooting

    Nothing comes out. Check file_path first. Wrong path or an unreadable file is the usual cause; make sure it's real and has one tag per line.

    Random tags fight each other. Pure random sampling will happily pick sitting and running in the same roll. Curate the file into themed lists (one for poses, one for lighting) and use separate picker nodes, or lean on filter/exclude to keep incompatible tags apart. Randomness is a feature, but it needs a sensible pool.

    Underscores showing up in the wrong place. Booru tags are inconsistent about this. replace_underscore defaults to false here on the assumption your tags want their underscores; if your model prefers spaced tags, turn it on. Match the setting to how your model was trained.

    Wrong paradigm for your model. Tag-style prompting is a Danbooru-lineage thing. On natural-language models like Flux or HiDream, a pile of comma-separated tags produces worse results than a written sentence would - those want prose. Use this node where tags are the native language.

    Categoryutils

    Inputs (10)

    NameTypeDefaultDescription
    file_pathSTRINGpath to a CSV file with a 'tag' column
    countINT51–1000number of tags to pick
    delimiterSTRING, string used to join picked tags
    replace_underscoreBOOLEANfalsereplace 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 — tags with higher counts are more likely to be picked
    seedINT00–18446744073709550000random seed — same seed produces the same selection
    excludeSTRINGcomma-separated tags to exclude from the pool before sampling (case-insensitive)
    filterSTRINGonly consider tags whose name contains this substring (case-insensitive); leave empty for no filtering

    Outputs (1)

    NameTypeDescription
    tagsSTRING