Nodes/ComfyUI-Alchemine-Pack/Separate Lora Tags
ComfyUI Node

Separate Lora Tags

Pull <lora:...> out of your prompt before it hits the encoder

By alchemine·Created about a year ago·Updated 2 days ago· 2
Separate Lora Tags
    • text_without_lora
    • text_with_lora
    text

    Lora tags are a weird kind of prompt content: they don't belong in the text encoder at all. When a prompt like <lora:character:0.8> 1girl, blonde hair gets tokenized, that <lora:...> block is just garbage characters from CLIP's point of view - the actual job is to load the LoRA, patch the model, and encode only the words. Separate Lora Tags is the clean splitter: one input, two outputs, and it's careful about commas and duplicate weights in a way that's easy to get wrong by hand.

    Why you'd reach for it

    Two genuinely different workflows want this. The first is the lora-tag loader pattern: the same pack has a Cached Load LoRA Tag node that takes <lora:...> tags and patches your model, returning the stripped text. Separate Lora Tags is the manual, inspectable version of that split - you get the clean prompt and the tag list, and you can route them anywhere. The second is dataset prep: captions for training shouldn't contain <lora:...> clutter at all, and this strips it while keeping the surrounding whitespace tidy.

    There's also a real convenience win baked in: when the same LoRA appears several times at different weights, the node dedupes to a single tag with the last weight winning - the README's example shows the same character file at 0.7 then 1.0 collapsing to just 1.0. Hand-rolling that is exactly the kind of logic that silently breaks.

    How it works

    It scans the text with a <lora:([^>]+)> regex, splits each match into name and weight on the last colon, and dedupes by name while keeping first-seen order. The clean-text side is where the care went: if a lora block is followed by a comma, the block plus its trailing comma is consumed so you don't get 1girl,, blonde; if there's no following comma, the preceding comma is preserved as the separator. Both outputs come out whitespace-clean.

    Inputs and outputs

    • text - the prompt containing <lora:...> tags.

    • text_without_lora - the prompt with all lora tags removed, spacing preserved as best as possible. Goes to your CLIP Text Encode.

    • text_with_lora - the deduplicated, space-joined lora tags (last weight wins, original order kept). Goes to a LoRA loader/stacker.

    Installation

    It's a member of ComfyUI-Alchemine-Pack. Use ComfyUI Manager (search "Alchemine"), install, restart - or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/alchemine/comfyui-alchemine-pack
    pip install -r requirements.txt
    

    Restart ComfyUI. The pack's only hard dependency is python-dotenv; no models or keys needed for the prompt nodes.

    Common issues

    The dedup logic keys on the lora name, and with the four-part format <lora:name:model_weight:clip_weight> the weight becomes part of the name it dedupes on - so foo:0.7:0.5 and foo:1.0:0.5 count as two different entries and both survive. For the common two-part <lora:name:weight> form, last-weight-wins works as advertised. And remember what this node is not: it doesn't load anything, it just rearranges strings. Wire text_with_lora into an actual loader or the tags are just decorations. If you want load-and-strip in one step, the pack's Cached Load LoRA Tag node is the single-node version.

    CategoryAlcheminePack/Prompt

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (2)

    NameTypeDescription
    text_without_loraSTRING
    text_with_loraSTRING