Nodes/comfyui_image_embeddings/Base64 Image Loader
ComfyUI Node

Base64 Image Loader

Unstick that base64 blob and turn it back into a real image

By baijunty·Created 8 months ago·Updated 3 months ago· 0
Base64 Image Loader
    • IMAGE
    • MASK
    • STRING
    base64_string
    name

    Somewhere in your life you're going to end up with an image as a base64 string. An API response, a JSON file, a row in a database, a colleague's "here's the image, it's base64" message. ComfyUI's built-in loader can't do a thing with that, and manually decoding, saving to a file, and loading it again is exactly the kind of busywork that makes you hate a workflow.

    Base64 Image Loader takes that string and turns it straight back into an IMAGE tensor, ready to feed into whatever your pipeline does next. It's the little brother of the pack's Image2Base64 node (encode image → base64); this is the return trip.

    How it works

    It's simpler than it looks. The node runs base64.b64decode() on your string, opens the resulting bytes as a PIL image, and pushes it through the same normalization pipeline ComfyUI's own LoadImage uses: RGB, scaled to 0–1 floats, shaped [B, H, W, C], with any alpha channel peeled off into a MASK (1.0 = transparent, the same convention ComfyUI uses). So whatever you feed it comes out the far end looking identical to a normally-loaded image.

    It also forces a re-run every time - the node's IS_CHANGED always returns "changed" - which is the right behavior for a loader. You don't want ComfyUI deciding a fresh base64 string "hasn't changed" and feeding you a stale image.

    The inputs that matter

    • base64_string - the raw base64 text. Required.
    • name - a label for the output. Per the pack README it's only used for the return value, i.e. it becomes the filename in the STRING output. Nothing more exciting than that.

    Three outputs: IMAGE (the tensor), MASK (alpha as a mask), and STRING (the name you gave it). Wire the image into img2img, an IP-Adapter-style reference path, a VAE decode, anything that takes an IMAGE.

    Installing it

    It's in the comfyui_image_embeddings pack by baijunty. ComfyUI Manager → search "image_embeddings" → install, then restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/baijunty/comfyui_image_embeddings
    

    No heavy dependencies here - torch, PIL and base64 are all already in your ComfyUI environment.

    Where people get burned

    The one real gotcha: strip the data-URI prefix. If your string looks like data:image/png;base64,iVBORw0..., the node chokes - it calls b64decode directly, which can't parse the data:image/png;base64, part. Most tools that export base64 include that prefix, so you'll want to remove it before pasting (any text editor, or a small string-processing node upstream).

    Otherwise this is a boring, dependable little node, and boring is good. It shows up in workflows that round-trip images through external services - generate something, encode it, ship it, get a result back as base64, and load it right back into the graph.

    Categoryutils

    Inputs (2)

    NameTypeDefaultDescription
    base64_stringSTRING
    nameSTRING

    Outputs (3)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK
    STRINGSTRING