Nodes/ComfyUI Model Toolkit/📤 Component Extractor
ComfyUI Node

📤 Component Extractor

Your checkpoint has a VAE stuffed inside it. Here's the box cutter

By StarAsh042·Created 2 years ago·Updated 20 days ago· 2
📤 Component Extractor
    • Extraction Result
    ◄model_name►
    ◄componentUNET►
    ◄output_nameextracted_component►

    A single-file checkpoint is three models wearing a trenchcoat: a UNet that does the denoising, a VAE that encodes pixels into latents and back, and a CLIP text encoder that turns your prompt into something the UNet can condition on - all packed into one .safetensors, because that's how single-file checkpoints were always shipped. CheckpointLoaderSimple takes that as a given and hands you MODEL, CLIP and VAE on three wires.

    Nothing in core ComfyUI gives those pieces back to you as individual files. 📤 Component Extractor does.

    When you actually need it

    Honest about the frequency: this is not a daily-driver node. Since the Flux generation, releases increasingly ship components separately anyway - diffusion weights here, a 16-channel VAE there, T5-XXL on the side - so on a current workflow there's often nothing to extract. Where it earns its keep is the long tail:

    • An older SD1.5 or SDXL checkpoint with a VAE baked in that you want as a file of its own.
    • A checkpoint whose decoder behaves badly, and you want to see what's in there before believing forum advice about colour.
    • Lining components up before a merge, so you're not about to average a text encoder with an autoencoder.

    How the cut works

    The node loads the whole file into CPU RAM - safetensors.torch.load_file, no header-only shortcut here, because it's about to write real tensors out. Then it groups every key.

    Grouping is the interesting part. If the key set matches one of the pack's six auto-detecting architecture templates (SD1.x and SDXL layouts, from sd-mecha, MIT) at 95% coverage or better, each key's ownership is read straight off the template - no guessing. Otherwise it falls back to prefix rules: cond_stage_model., conditioner., text_encoder. and text_encoder_2. go to CLIP; first_stage_model. and vae. go to VAE; the UNet prefix is decided by a vote among model.diffusion_model., diffusion_model., model.model. and net.. CLIP is checked first on purpose - otherwise the text encoder's encoder.* keys get eaten by the VAE group. SDXL's two text encoders collapse into one CLIP, since this pack only has three buckets.

    Then it copies the selected component's keys into a new state dict and writes it. Keys keep their original prefixes, so you get a fragment of a checkpoint, not a miniature checkpoint.

    The three fields

    model_name is the source file, chosen from models/checkpoints. component is UNET, VAE or CLIP - that's the whole list; EMA weights and unclassified keys stay behind. output_name is optional: blank gives you <model>_<component>.safetensors, and a missing extension gets .safetensors appended.

    One output: Extraction Result, a STRING carrying the key count, the full save path (ComfyUI/models/model_toolkit_extracted/) and - the useful bit - a note like template sdxl-sgm matched 1214/1214 keys. A full match means the layout was recognised and the component complete; a ragged number means the prefix heuristics did the work, so check the count yourself.

    This is a file factory, not a loader. There's no MODEL, CLIP or VAE socket on it. Beginners try to wire it into a KSampler; there's nothing to wire. Run it, read the string.

    Install

    Manager, search ComfyUI Model Toolkit, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StarAsh042/ComfyUI_model_toolkit.git
    pip install -r ComfyUI_model_toolkit/requirements.txt
    

    Requirements are safetensors>=0.3.0 and pyyaml>=5.4.0. Torch comes from ComfyUI and is deliberately not declared, so the pip step can't touch it. Restart afterwards - the model_toolkit_extracted folder is registered at import time, along with the routes the sibling inspector needs.

    Where people get burned

    The dropdown only lists checkpoints. Hardcoded in the node's input definition, with no widget to change it. A VAE sitting in models/vae, or a Flux-era diffusion_models/*.safetensors, cannot be selected here at all. If that's what you're after, this node isn't the tool.

    Errors arrive as text, not exceptions. Every failure returns a string with a ❌ in it: ❌ VAE component not found, ❌ Failed to load model file. The node goes green in the queue and nothing turns red. If the run "worked" but no file appeared, read the output.

    Memory. Peak RAM is roughly the file size, since it's loaded before anything is written. SDXL at fp16 is about 6.5 GB. Fine on 32 GB, miserable on a laptop.

    .ckpt is a coin flip. Old pickles go through torch.load with weights_only=True - the right call for safety, but a legacy file carrying non-tensor objects can fail outright. Use .safetensors when you have the choice.

    Matching filenames get overwritten without a prompt. Two extractions with the same output_name means the second silently replaces the first, and extracted_component - the default - is a terrible name to reuse.

    A fresh extraction doesn't show up in the Replacer's dropdown. That list is built when ComfyUI asks the node for its inputs - refresh the browser page after extracting.

    Categorymodel_toolkit/Editing

    Inputs (3)

    NameTypeDefaultDescription
    model_nameCOMBO0 options:
    componentCOMBOUNET3 options: UNET, VAE, CLIP
    output_nameSTRINGextracted_component—

    Outputs (1)

    NameTypeDescription
    Extraction ResultSTRING—