Nodes/Nukun_ComfyUI_Nodes/T5 Token-based Prompt Balancer
ComfyUI Node

T5 Token-based Prompt Balancer

Equal-length positive/negative T5 prompts, the thing Pony v7 and Flux quietly need

By OnekoSL·Created 3 months ago·Updated 11 days ago· 1
T5 Token-based Prompt Balancer
  • tokenizer
  • positive
  • negative
target768
positive
negative

If you've ever run a T5-conditioned model (Flux, AuraFlow, or the Pony v7 family) and noticed the negative prompt barely doing anything, the cause might not be the words - it's the token count. T5 pads its sequences to a fixed length, so a short negative prompt gets drowned in padding tokens while a long positive prompt runs at full strength. T5 Token-based Prompt Balancer is the fix: it measures both prompts and encodes them at the same token length, so your negatives actually push back.

This is a small, focused node from the Nukun personal pack. It's been around long enough that the pack's README treats it as the legacy tool - the newer T5 Equal-Length Prompt Balancer (Nukun) is the safer Pony v7/AuraFlow pick - but T5Balancer is still the one people search for, and it does one thing cleanly.

How it works

You feed it a T5 CLIP tokenizer plus your positive and negative text. Reading the source, it does two passes over the T5 tokenizer options:

  1. It sets a minimum token length (pile_t5xl_min_length) equal to your target, tokenizes the positive prompt, and encodes it. Long positives are preserved, short ones are extended toward the target.
  2. It then sets the negative prompt's padding (pile_t5xl_min_padding) to match the positive's actual token count, and encodes that too.

Result: both conditionings carry the same effective token count, so the negative gets an equal seat at the table instead of being a few padding tokens rattling around in a long sequence.

The inputs that matter

  • tokenizer - the loaded T5 tokenizer (a CLIP from a T5-backed loader; this is not for SD1/SDXL CLIPs).
  • target - minimum number of tokens to balance toward. Default 768, range 0–4096. If your positive prompt is already long, the effective length is driven by the prompt, not this number.
  • positive, negative - your prompt texts.

Two outputs, both CONDITIONING: positive and negative. Wire them into the sampler's positive/negative paths exactly like the output of any CLIP Text Encode.

The honest take

If you're on Pony v7 or AuraFlow and your negatives feel weak, this is worth trying - the mechanism is real and it costs nothing. On a small negative like worst quality, bad anatomy, the padding is what makes the difference. Where people get burned: wiring in an SDXL or SD 1.5 CLIP and wondering why nothing balances (T5-specific options simply don't exist there), or setting target absurdly high and padding every prompt with hundreds of tokens of dead weight - set it to the length your real prompts actually reach. If you're starting fresh, the pack's equal-length variant is the maintained path, but this node still works fine and still appears in old Pony v7 workflows.

Installing it

Part of Nukun_ComfyUI_Nodes. ComfyUI Manager (search "Nukun"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/OnekoSL/Nukun_ComfyUI_Nodes

Restart ComfyUI. Runtime deps are numpy, Pillow, scipy, and PyWavelets; the T5 tokenizer itself comes from your model loader, not this pack. No model downloads.

CategoryNukun/Conditioning

Inputs (4)

NameTypeDefaultDescription
tokenizerCLIPThe loaded T5 Tokenizer to use.
targetINT7680–4096Minimum number of tokens to balance toward.
positiveSTRING
negativeSTRING

Outputs (2)

NameTypeDescription
positiveCONDITIONING
negativeCONDITIONING