Nodes/MoonNe_Nodes/Batch Conditional Text Weight
ComfyUI Node

Batch Conditional Text Weight

Conditional Text That Also Randomizes the Weights — the Fiddly One

By Moon-NE·Created 2 months ago·Updated 2 months ago· 0
Batch Conditional Text Weight
    • STRING
    batch_index0
    text
    greater_than0
    less_than999
    probability1.00
    min_weight1.00
    max_weight1.40
    seed0

    The same conditional gate, but it hands you weighted tags

    Take Batch Conditional Text - the frame-range gate that emits text only when the current batch index is in range, optionally on a coin flip - and add one twist: when it does fire, it doesn't hand you the text as-is. It splits your text into comma-separated tags and wraps each one in an attention weight that it rolls randomly between two bounds you set. Output looks like (knight:1.23),(dragon:1.05),(armor:1.18). Every qualifying frame gets a fresh, slightly different emphasis.

    That's the whole pitch of Batch Conditional Text Weight, the sibling node from Moon-NE's MoonNe_Nodes pack. It's the one I'd call the fiddly member of the family: the range and probability logic is identical to its sibling, but the weight mechanic drags in some model-specific baggage you should know about before you build a workflow around it.

    How it works

    The gating is copy-paste from BatchConditionalText, and it's worth understanding because the values swap meaning depending on which is bigger:

    • greater_than < less_than → fires inside the range (greater_than <= index <= less_than).
    • greater_than > less_than → fires outside the range (below less_than OR above greater_than).
    • greater_than == less_than → fires only at that exact index.

    When the gate opens, the node splits your text on commas (it even converts full-width so your CJK-style punctuation doesn't break things), strips each tag, and for each one draws a random weight from uniform(min_weight, max_weight) - formatted as (tag:1.23) - then re-joins with commas. If min_weight > max_weight, it quietly swaps them rather than erroring. Combined with the probability roll (0–1) and the seed, every frame gets a deterministic-but-unique draw via f"{seed}_{batch_index}".

    The baggage: (tag:1.3) is a lie on modern models

    This is where the fiddly part bites. Attention weights like (knight:1.2) are CLIP-era syntax - they're real on the SDXL lineage (Illustrious, NoobAI, Pony V6 and friends), where the text encoder was trained to read them. But the 2026 crop of LLM-encoded models - Flux 2 Klein, Z-Image, Anima, that whole family - silently discard them: the encoder wrapper passes disable_weights=True and the numbers do nothing. The tags still matter; the weights are decorative.

    So before you wire this node into your workflow, know which model you're talking to. On an SDXL-lineage checkpoint this node is a legit per-frame prompt-roulette: gate it to a frame range, set min_weight: 0.8, max_weight: 1.5, and watch emphasis wander across the animation. On a modern LLM-encoded model, you're paying the complexity for a plain random tag-picker - the numbers do nothing, and you'd be better off with plain Batch Conditional Text and a wildcard node. Neither is wrong; knowing which you're on is everything.

    Inputs and output

    • batch_index (INT) - the current frame/batch index. Feed it from your animation loop or counter - ComfyUI won't auto-increment it for you, so a constant 0 means every frame is "frame 0" and the gate behaves uniformly across the whole batch.
    • text (STRING, multiline) - your comma-separated tag list. Commas are load-bearing here.
    • greater_than, less_than (INT) - the range pair described above.
    • probability (FLOAT, 0–1) - chance to fire on a qualifying frame.
    • min_weight, max_weight (FLOAT, 0–10) - bounds for the per-tag random weight. Defaults 1.0 and 1.4 are a sensible conservative spread.
    • seed (INT) - base seed for the per-frame draw.

    Output is a single STRING - the weighted tag string, or "" when the gate stays shut (which is harmless chained into a CLIP Text Encode). The node also overrides IS_CHANGED to force re-evaluation every run, so the roll never gets frozen by ComfyUI's cache.

    Install

    Same as the rest of the pack, and it's light - pure Python stdlib, no requirements.txt, no model files:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Moon-NE/MoonNe_Nodes
    

    Or search for MoonNe_Nodes in ComfyUI Manager and hit Install, then restart ComfyUI. This is a niche node for a niche need - per-frame randomized emphasis on a CLIP-encoder model - but when that's what you're building, it's the shortest path to it.

    CategoryText/Conditional

    Inputs (8)

    NameTypeDefaultDescription
    batch_indexINT00–999999
    textSTRING
    greater_thanINT0
    less_thanINT999
    probabilityFLOAT1.000–1
    min_weightFLOAT1.000–10
    max_weightFLOAT1.400–10
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    STRINGSTRING