ComfyUI Node

Remove Weights

Strip the (cat:1.2) noise out of a prompt in one pass

By alchemine·Created about a year ago·Updated 2 days ago· 2
Remove Weights
    • processed_text
    text

    If your prompt has ever come back from an LLM prompt helper or a TIPO-style tagger with (masterpiece:1.2) and ((best quality)) welded onto every other tag, this is the node you're looking for. Remove Weights takes a weighted prompt and hands back the plain tags: (cat:1.2) becomes cat. That's the whole job, and it does it cleanly.

    Why you'd reach for it

    Weighted syntax is an A1111 convention that ComfyUI also understands - (word:1.2) and ((word)) mean "emphasize this" to CLIP-era encoders (SD 1.5, SDXL, and the Danbooru-trained anime family like Illustrious and NoobAI). But a lot of pipeline stages want the unweighted version:

    • You're saving captions for a training dataset and don't want (foo:1.2) noise in your .txt files.
    • A prompt generator injected weights and you want the raw tag list back so you can edit or reorder it.
    • You're feeding a prompt into another pack node that parses tags itself and chokes on the parenthesized syntax.

    It's the inverse of the "add weights" workflow - every once in a while you just need the plain words.

    How it works

    The node splits your text on BREAK first, keeping the separators and their whitespace intact, then splits each segment into tags. The tag splitter is parenthesis-aware, so a comma inside (highres, absurdres) doesn't break the group. Each tag then gets regex-stripped:

    • (cat:1.2)cat
    • (cat:1.2:1.3)cat (the two-number form, for SDXL model/clip weights)
    • (cat), ((cat)), [cat], [[cat]]cat

    The parens-and-brackets unwrap is worth knowing: this node doesn't just remove explicit weights, it flattens emphasis syntax entirely. That's usually exactly what you want from a node called Remove Weights, but if you were deliberately using ((word)) emphasis, this removes it.

    Inputs and outputs

    Just two things, and one of them is on the left edge of the node:

    • text - the weighted prompt you want cleaned.
    • processed_text - the output, wired into whatever wants plain tags (a CLIP Text Encode, a caption saver, or the next prompt-cleaning node in a chain).

    No CLIP input, no model, nothing to configure. It's a pure string transformation.

    Installation

    This node ships in the ComfyUI-Alchemine-Pack repo, together with its siblings like SDXLAutoBreak, SDXLTokenAnalyzer, and SaveImageWithText. The easiest route is ComfyUI Manager: search for "Alchemine" and install the pack, then restart. Or clone it by hand:

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

    Then restart ComfyUI. The only hard dependency in the whole pack is python-dotenv - no model downloads, no heavy packages. The .env file the README mentions is optional and only matters for the pack's API-key-hungry nodes; none of the prompt nodes need it.

    Common issues

    There aren't many failure modes for a string cleaner, but one gotcha: the node runs tag-by-tag on comma-separated tags, so if your prompt uses sentence-like prose rather than tag lists, the results can look a little flattened - (a girl:1.2) standing in (a field:1.1) becomes a girl standing in a field, weights gone, grammar intact. That's the point. If you have BREAK separators, they're preserved, so a weighted prompt with BREAK still comes back with its segment structure. Feed the output into a text-preview node on your first run and you'll see exactly what changed.

    CategoryAlcheminePack/Prompt

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    processed_textSTRING