Nodes/Model Utility Toolkit/Prune Embedding Keys
ComfyUI Node

Prune Embedding Keys

Prune Embedding Keys — strip tensors out of a .safetensors embedding

By silveroxides·Created about a year ago·Updated 4 days ago· 14
Prune Embedding Keys
    • output_path
    embedding
    keys_to_prune
    use_regexfalse
    output_filenamepruned_embedding

    This is the "cut a specific tensor out of an embedding file and save the result" node. It's part of silveroxides' ComfyUI-ModelUtils pack - the same author behind the widely-used Chroma-GGUF quantizations - and it's the surgical-edit counterpart to that pack's read-only inspector. If you've ever opened an embedding and found it's carrying keys you don't want, this is how you actually get rid of them instead of just knowing they're there.

    Why you'd want this at all. Embeddings are tiny by design - 10-80KB, versus 10-200MB for a LoRA - because they're just a handful of learned vectors bound to a trigger word in the text encoder's space. Most of the time there's nothing to prune. But multi-vector embeddings occasionally carry extra tensors you didn't ask for (duplicate concept vectors, leftover training artifacts, keys a specific loader chokes on), and stripping them down to just what you need is a legitimate reason to reach for this instead of leaving the file as-is.

    How it works. Load the embedding, remove any tensor whose key matches what you typed into keys_to_prune, and write the result to a fresh .safetensors file. It never touches your original - this is non-destructive by construction, which is the right default for anything editing model weights.

    Inputs that matter. embedding picks the source file from your embeddings folder. keys_to_prune is a multiline field - put the exact tensor names you want gone, one per line. use_regex flips matching from literal names to regex patterns, handy if you're cutting a whole family of keys at once rather than typing each one out. output_filename defaults to pruned_embedding; change it before running twice or you'll overwrite your own output. The single output is output_path, a string telling you where the new file landed.

    Installing it. ComfyUI Manager, search "Model Utility Toolkit" - or cd ComfyUI/custom_nodes && git clone https://github.com/silveroxides/ComfyUI-ModelUtils and restart. No extra dependencies called out in the README, nothing to download; it works directly on embedding files already in your folder.

    The one step you shouldn't skip. You need the exact key names before you can prune anything, and guessing gets you nowhere - a typo'd key just silently matches zero tensors and your "pruned" file comes out identical to the original. Run the same pack's Get Embedding Metadata & Keys node first, copy the real names from its keys output, then come back here. use_regex off means an exact match is required, which is safer against typos but less forgiving if you're not sure of the precise casing.

    What pruning can't fix. It's tempting to think removing keys might make an incompatible embedding load somewhere it otherwise wouldn't. It won't. Embeddings are locked to the exact text encoder they were trained against - an SD 1.5 vector means nothing to SDXL's OpenCLIP, and neither means anything to the Qwen3-class encoders that Z-Image and Flux 2 actually use. Pruning changes what's inside a compatible file; it doesn't change which architecture the file targets. If an embedding isn't working, check compatibility first - renaming or pruning its keys won't rescue a fundamentally mismatched file.

    One execution quirk worth knowing. This node isn't flagged as a workflow output, so if output_path isn't wired to anything downstream, ComfyUI's graph pruning can skip the node entirely and nothing gets written - even though the file's saved as a side effect, not through the graph connection. Route output_path into a Show Text node (or anything, really) so the branch actually executes.

    CategoryModelUtils/Keys

    Inputs (4)

    NameTypeDefaultDescription
    embeddingCOMBO0 options:
    keys_to_pruneSTRING
    use_regexBOOLEANfalse
    output_filenameSTRINGpruned_embedding

    Outputs (1)

    NameTypeDescription
    output_pathSTRING