Nodes/ymc-node-suite-comfyui/prompt - shuffle
ComfyUI Node

prompt - shuffle

Shuffle your prompt tags with a seed you control

By YMC-GitHub·Created 3 years ago·Updated about a year ago· 20
prompt - shuffle
    • STRING
    text
    keep_n_token0
    seed0

    Prompt order is a lever most people ignore until it bites them. On SDXL-lineage models, the first tags in a prompt get the strongest attention, so shuffling the order of your tags changes the emphasis - and therefore the image - even though every tag is still there. prompt - shuffle exploits that on purpose: it randomizes tag order, keeps an optional prefix fixed, and seeds the shuffle so the same seed always gives the same order.

    Where this shines is variation farming. You have a solid prompt, you want 20 takes on it without deleting or inventing tags - run it through shuffle with a changing seed, and each run re-emphasizes different parts of the prompt. Cheap exploration, no prompt editing.

    How it works

    The node flattens your prompt to comma-separated tags (line breaks become commas), splits into a list, and shuffles with Python's random seeded from the seed input. The keep_n_token field - despite being a string field, a quirk of this pack - tells it how many leading tags to hold in place. Set it to 1 and your first tag stays first (a character name, say) while everything after it scrambles.

    That anchor is the detail that makes the node usable for real: you can pin "character identity" at position zero and let the style/pose/environment tags vary around it. The default 0 shuffles everything.

    Inputs and outputs

    • text - the prompt to shuffle
    • keep_n_token - how many leading tags stay fixed (string field; "0" shuffles all)
    • seed - the shuffle seed (int). Same seed + same text = same order.
    • STRING output - the shuffled, comma-separated prompt

    Installing it

    Part of ymc-node-suite-comfyui:

    • ComfyUI Manager → search ymc-node-suite-comfyui → Install → restart, or
    cd ComfyUI/custom_nodes
    git clone https://github.com/YMC-GitHub/ymc-node-suite-comfyui
    

    restart, and pip install -r requirements.txt on a manual clone (four yors_* helper libs; the pack's auto-install is commented out). No models, no GPU.

    Search prompt / shuffle on the canvas or use the right-click ymc suite menu.

    Common issues

    • keep_n_token is a text field. Type 1, not 1.0 - it's parsed as an int, and 0 (the default) means "no anchor, shuffle everything." People expect 1 to mean "keep one tag" and it does, but forgetting to change it from 0 is the usual "why did my anchor move" complaint.
    • Shuffle ≠ new content. Every tag is preserved; only the emphasis changes. If you want new subject material, that's prompt - random.
    • Seeds only match with the same input. Change one tag and the same seed produces a different order - that's normal, the seed reseeds the whole shuffle.
    • Weights survive the shuffle - (tag:1.2) is treated as a single tag token, so weighted tags shuffle as units. That's almost certainly what you want.
    • WAS Node Suite conflicts on the pack's io/save nodes can show up as warnings if you run both packs - unrelated to this node.

    If you want the shuffle to also dedupe or tidy the prompt first, chain prompt - dup and prompt - std upstream - that's the standard ymc prompt-cleanup pipeline.

    Categoryymc suite/text

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    keep_n_tokenSTRING0
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    STRINGSTRING