LoRA Weight Balancer
Make Your LoRA Stack Random Without Nuking the Image
- text_out
You've got six LoRAs in a pile and you want the graph to roll the dice on weights every run - but stacking random weights is how you end up with a melted face at total strength 3.4. The LoRA Weight Balancer fixes the part nobody thinks about: it doesn't just randomize, it balances. Replace every --- placeholder in your prompt with a random weight, then scales the whole set so it sums to roughly your target_sum. You get variety without the sum blowing past 1.0 and turning your subject into paint.
It comes from artyclaw/artyclaw-comfy, a one-author pack the README describes as "a bunch of helpful ComfyUI nodes for prompt logic, IO, and RNG" - built for the author's own workflows, published in case anyone else wants them. This is the pack's most-searched node, and it's easy to see why.
How it works
Feed it a prompt where the LoRA weights are a placeholder, like <lora:charStyle:--->, <lora:detail:--->. The node:
- Counts how many times the placeholder appears.
- Draws a random weight for each, between
min_weightandmax_weight. - Scales them all so the sum lands on
target_sum. - Clamps each back into the min/max bounds - the clamp wins over the exact sum, which the source explicitly calls a "priority rule."
- Formats to two decimals and swaps the placeholders in one at a time.
Seeded with the seed input, the whole thing is deterministic: same seed, same weights, every run. Wire that seed to your global seed source and variations stay reproducible.
The inputs that matter
Only a handful do anything for a beginner:
- text - your prompt with placeholders where weights go.
- placeholder - the marker to replace,
---by default. - target_sum - what the weights should add up to. 1.0 is the sane default for a LoRA stack.
- min_weight / max_weight - the per-tag bounds. Defaults of 0.1 and 1.5 give room to breathe.
- seed - reproducibility.
One output, text_out, which is exactly what you'd run through a CLIP text encode. There's no tag parsing here - the node is gloriously dumb about the <> syntax around your placeholder, which is the point: it works with any text that contains your marker.
Install
It's a one-file node in a plain Python pack with no requirements.txt and no model downloads. Easiest via ComfyUI Manager (search ArtyClaw Comfy Nodes), or:
cd ComfyUI/custom_nodes
git clone https://github.com/artyclaw/artyclaw-comfy
Restart ComfyUI. That's it - everything it needs (random, string ops) ships with Python.
Where people get burned
The trap is the clamp-vs-sum interaction. If you set min_weight high and stack lots of LoRAs, scaling gets fought by clamping and the final sum drifts from target_sum - not a bug, a design decision, but worth knowing when you're chasing an exact total. Also, if the placeholder doesn't appear in the text at all, the node just passes the text through unchanged. It doesn't warn you, so a typo'd placeholder quietly does nothing. Check the output string in a text-viewer node once if your weights look frozen.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| placeholder | STRING | --- | — |
| target_sum | FLOAT | 1.000–10 | — |
| min_weight | FLOAT | 0.100–5 | — |
| max_weight | FLOAT | 1.500–5 | — |
| seed | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text_out | STRING | — |