Nodes/RES4LYF/TextShuffle
ComfyUI Node Runs on cloud

TextShuffle

Randomize word order in a prompt, reproducibly

By ClownsharkBatwing·Created 2 years ago·Updated 17 days ago· 1,222
TextShuffle
    • shuffled_text
    text
    separator
    seed0

    TextShuffle is the odd one out in RES4LYF - no sigmas, no solvers, no latents. It just takes a string, splits it on a separator, shuffles the pieces, and joins them back up. Feed it a prompt and you get the same words in a scrambled order. Small node, one honest job.

    Why bother? Prompt order matters more than people expect. Tokens near the front of a prompt tend to carry more weight, and models latch onto phrasing in ways that are hard to predict. Shuffling the word or tag order is a cheap way to explore that - to see whether "sunlit, misty, forest" pulls differently than "forest, misty, sunlit," or to break a model out of a rut where it keeps composing the same way. It's especially handy for tag-style prompts (the comma-separated kind SDXL and anime finetunes love) where the tags are semantically order-independent to you but not to the model.

    How it works

    You give it text, a separator, and a seed. It splits the text on the separator into chunks, shuffles those chunks using the seed as the random source, and re-joins them with the same separator. Because the shuffle is seeded, it's deterministic: the same text plus the same seed always produces the same shuffle. That's the important part - it's reproducible, so a result you like can be regenerated instead of lost.

    The inputs and output that matter

    • text (STRING) - the prompt to scramble.
    • separator (STRING, default a single space " ") - what to split on. Leave it as a space to shuffle individual words; set it to ", " to shuffle whole comma-separated tags instead of chopping them into words. This is the setting people get wrong, so decide which granularity you actually want.
    • seed (INT, default 0) - the shuffle's random source. Change it to get a different ordering; keep it to lock one in.

    Output is a single shuffled_text (STRING). Wire it straight into the text input of a CLIP Text Encode (or any node that takes a prompt string), and encode as usual.

    How to install it

    ComfyUI Manager: search RES4LYF, install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/ClownsharkBatwing/RES4LYF/, then in your venv run pip install -r requirements.txt (portable ComfyUI: use the embedded python's pip). Restart and hard-refresh with F5. TextShuffle itself has no special dependencies - it's plain string handling - so if the rest of the pack loads, this node loads.

    Common issues

    The one real trap is the separator. If you leave it on the default space and your prompt is written as long comma-separated tags, TextShuffle will happily chop inside your tags - "detailed background" becomes two loose words that can drift apart in the shuffle and lose their meaning. If you're working with tags, set the separator to ", " so whole tags move as units. If you're working with natural-language sentences, shuffling words will usually produce nonsense grammar; that's fine for a chaotic exploration pass but not for a polished prompt.

    Beyond that, remember it's reproducible, not random-per-run. If you want a fresh shuffle every generation you have to actually change the seed (wire it to a seed that increments, or set control-after-generate accordingly) - otherwise it'll faithfully hand you the exact same scramble every time and you'll wonder why nothing's changing.

    CategoryRES4LYF/text

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    separatorSTRING
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    shuffled_textSTRING