Nodes/ComfyUI Simply Nodes/Random Style Prompt
ComfyUI Node

Random Style Prompt

Random style tags from a text file, seeded and repeatable

By Wicloz·Created 2 years ago·Updated 11 months ago· 1
Random Style Prompt
    • STRING
    style_def_file
    seed0
    strength0.10
    override

    Random Style Prompt is a tiny node that makes random style decisions for you. It reads a plain .txt file from ComfyUI/models/styles/, where each line is one style token, and returns a random subset of those lines joined into a comma-separated string. Wire that into your CLIP Text Encode and every run gets a different flavor - but one that's fully controlled by a seed.

    Let's get the biggest gotcha out of the way first: strength is not how strongly the style applies. It's the probability that any given line gets included. Default 0.1 means each line has a 10% chance of appearing in the output. Crank it to 1.0 and every line always shows up; drop it to 0 and you get an empty string. It's a dice roll per line, not a volume knob.

    How it works

    The mechanism is short: it seeds a NumPy random generator with your seed, then walks the file line by line and keeps each line whenever a random draw is below strength. Because the RNG is seeded, the same seed + same file + same strength always produces the same output. That's the part that makes it useful rather than chaos: fix the seed, vary the style file or strength, and you can compare style sets while keeping everything else constant.

    One more escape hatch: the override input. If it contains any non-whitespace text, the node returns it verbatim and skips the random logic entirely. So you can have one node that's random most of the time but pinned to a specific style when you want it.

    Inputs and output

    • style_def_file - a dropdown of every *.txt in ComfyUI/models/styles/. If the folder doesn't exist or is empty, the dropdown has nothing to show, and you'll need to create the folder and a file.
    • seed - from 0 up to 2^64−1. This is your reproducibility handle.
    • strength (default 0.1, 0–1, step 0.01) - per-line inclusion probability, not intensity.
    • override - multiline text that, when non-blank, is output as-is.

    The single output is a STRING, ready for a text encoder.

    Setting up your style file

    There's nothing to download - you bring the styles. Create ComfyUI/models/styles/my_styles.txt and put one tag per line:

    lineart,
    watercolor,
    night,
    neon, cyberpunk,
    

    If you're on an Illustrious/Anima-lineage model, danbooru-style tags work great, and the model reads comma-joined tags natively - which is exactly what this node emits. One practical note: you'll need to refresh/recreate the node (or restart ComfyUI) after adding a new file so it shows up in the dropdown, since the list is scanned when the node initializes.

    Installing it

    ComfyUI Manager → search "ComfyUI Simply Nodes" → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Wicloz/ComfyUI-Simply-Nodes
    

    No requirements.txt, no models, nothing extra. It uses NumPy, which stock ComfyUI already ships.

    Common issues

    • Empty output: the file is empty, every line lost the dice roll at low strength, or override is blank and the folder path is wrong. Check the file exists under ComfyUI/models/styles/ relative to your ComfyUI root.
    • Same output every time: that's the seed working as intended - change the seed to shuffle.
    • "Random" but nothing changes: if every line in your file has probability ~0.1 and you have few lines, you'll often get very similar output. Lower is more adventurous.

    It's a blunt instrument next to a full dynamic-prompt system, but it's seeded, deterministic, and dead simple - which is usually all you actually want for exploring style space.

    Categoryprompt

    Inputs (4)

    NameTypeDefaultDescription
    style_def_fileCOMBO0 options:
    seedINT00–18446744073709550000
    strengthFLOAT0.100–1
    overrideSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING