Nodes/ComfyUI-Apt_Preset/text_wildcards
ComfyUI Node

text_wildcards

Random lines out of .txt files, stitched into a prompt — reproducibly

By cardenluo·Created 2 years ago·Updated a day ago· 324
text_wildcards
    • text
    output_join_ruleComma
    custom_join{text0},{text1},{text2},{text3},{text4},{text5},{text6},{text7},{text8}
    input_split_ruleLine
    custom_split
    text0
    text1None
    text2None
    text3None
    text4None
    text5None
    text6None
    text7None
    text8None
    seed0

    Wildcards - picking a random line from a text file and dropping it into your prompt - are one of those ideas every dynamic-prompt tool eventually reimplements. text_wildcards is ComfyUI-Apt_Preset's version, and it's a good one: up to eight wildcard files, a fixed text prefix, a seed so the "random" is repeatable, and full-width/Chinese punctuation handled properly. If you've been faking wildcards with random nodes and string math, this is the tidy replacement.

    It's part of the cardenluo mega-pack. Note up front: the pack is Chinese-first and barely referenced in English communities, so the node's own descriptions are in Chinese - but the face is readable, and the wildcard file convention is exactly what you'd hope.

    How it works

    text0 is your custom prefix - type anything, Chinese included. text1 through text8 are dropdowns listing available wildcard files; set each to None to skip that slot. Every selected file yields one randomly chosen line, and the picks are joined by output_join_rule (default Comma - which, like the rest of this pack, means a full-width ; switch to Space or Pipe for ASCII work).

    The seed is the star. Same seed, same picks, every time. That's the difference between "wildcards" and "chaos": you can keep a seed while changing only the seed to explore variations, then re-run an exact combo to debug. input_split_rule controls how each file's content is split into choices - default Line (one line = one choice), but you can split on commas, pipes, periods, or a custom_split string. So a file like red, green, blue works with the Comma rule, or line-per-choice if that's how it's laid out.

    Where the files live

    Two directories, and the name collision rule matters:

    • ComfyUI/models/Apt_File/wildcards - "dir1" in the dropdown, wins on duplicate names.
    • the pack's own wildcards/ folder - "base_path", ships with ~85 files (actor, bird, weapon, time, emotion, etc.). Add your own files here or in dir1 as .txt, UTF-8, and restart.

    So you can override any built-in list by dropping a same-named file into models/Apt_File/wildcards. That's the intended workflow: your version, your way.

    Inputs and outputs

    • text0 - fixed prefix.
    • text1–text8 - file dropdowns (None to skip).
    • seed, input_split_rule, custom_split, output_join_rule, custom_join (only in Custom mode).
    • Output: text - the assembled prompt string.

    Installing it

    ComfyUI Manager → search ComfyUI-Apt_Preset, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cardenluo/ComfyUI-Apt_Preset
    

    Restart. No extra model downloads for this node - the wildcard files come with the pack, and your own go into models/Apt_File/wildcards (created for you).

    Common issues

    A selected file that goes missing just logs a warning and skips that slot (with a Chinese note) rather than crashing - check console output if a slot silently comes up empty. Encoding: files should be UTF-8; anything else logs a warning and returns nothing. And the full-width comma default catches people who feed output straight into English tag models. Otherwise the only real gotcha is pack-wide: update the pack and your file dropdowns repopulate from disk, so paths won't drift.

    CategoryApt_Preset/prompt

    Inputs (14)

    NameTypeDefaultDescription
    output_join_ruleCOMBOComma8 options: Line, Custom, Space, Comma, Period, Semicolon, +2
    custom_joinSTRING{text0},{text1},{text2},{text3},{text4},{text5},{text6},{text7},{text8}
    input_split_ruleCOMBOLine8 options: Line, Custom, Space, Comma, Period, Semicolon, +2
    custom_splitSTRING
    text0STRING
    text1COMBONone86 options: None, base_path | vid3physicalV2, base_path | tropical_fish, base_path | vid4camera, base_path | natural_setting, base_path | town, +80
    text2COMBONone86 options: None, base_path | vid3physicalV2, base_path | tropical_fish, base_path | vid4camera, base_path | natural_setting, base_path | town, +80
    text3COMBONone86 options: None, base_path | vid3physicalV2, base_path | tropical_fish, base_path | vid4camera, base_path | natural_setting, base_path | town, +80
    text4COMBONone86 options: None, base_path | vid3physicalV2, base_path | tropical_fish, base_path | vid4camera, base_path | natural_setting, base_path | town, +80
    text5COMBONone86 options: None, base_path | vid3physicalV2, base_path | tropical_fish, base_path | vid4camera, base_path | natural_setting, base_path | town, +80
    text6COMBONone86 options: None, base_path | vid3physicalV2, base_path | tropical_fish, base_path | vid4camera, base_path | natural_setting, base_path | town, +80
    text7COMBONone86 options: None, base_path | vid3physicalV2, base_path | tropical_fish, base_path | vid4camera, base_path | natural_setting, base_path | town, +80
    text8COMBONone86 options: None, base_path | vid3physicalV2, base_path | tropical_fish, base_path | vid4camera, base_path | natural_setting, base_path | town, +80
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    textSTRING