Nodes/ComfyUI-FairLab/Base64 To Image
ComfyUI Node

Base64 To Image

From API string back to pixels — Base64 To Image decodes into a real tensor

By yanhuifair·Created 2 years ago·Updated 3 months ago· 2
Base64 To Image
    • image
    string

    Somewhere in your ComfyUI career you will get an image back as a base64 string - from an API response, a browser canvas capture, a JSON payload, a client that can't hand you a file. This node is the decoder for exactly that moment. Paste or wire in a base64-encoded PNG and it hands you a proper IMAGE tensor you can plug into any image socket in the graph, no file on disk involved.

    It's the reverse of the pack's Image To Base64 node, and the two are meant to be a pair: encode an image to ship it out, decode one that's come back in. The mechanism, straight from the source, is deliberately forgiving about formats. It takes your string, splits on the first comma - so it accepts both a bare base64 payload and one with the data:image/png;base64, data-URI prefix attached - then base64.b64decodes the payload, opens the bytes with PIL, and converts to a ComfyUI tensor. The prefix handling is the detail that saves you from a whole class of "my string won't decode" bugs, because half the services out there return the prefixed form and half don't.

    The inputs and outputs are minimal:

    • string - the base64 PNG data, with or without the data-URI prefix.
    • image - the decoded IMAGE tensor, ready to wire into a VAE encode, a save node, a ControlNet preprocessor, whatever.

    Where this shows up in practice: any workflow that talks to an external service. The KB's image-I/O doc leans heavily on how ComfyUI treats images as files with embedded metadata, and base64 is the fileless alternative - the image exists only as a string in memory until you decode it. That's the use case for this node: API-integration workflows, remote job runners, or a pipeline where a previous node produced a base64 string and you need pixels again.

    A few honest notes. The node decodes PNG data; if your service hands you a base64 JPEG, PIL can usually open it anyway, but the pack's encoder produces PNGs and the node's naming says PNG - stick with PNG round-trips and you're on solid ground. And since the output is a tensor, not a file, there's no embedded workflow metadata to recover from it - if you care about the "image is the project file" property, decode and then re-save through a normal save node.

    Install is the standard pack path. ComfyUI Manager → Install Custom Nodes → search ComfyUI-FairLab → install → restart:

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

    Restart, then search "Base64 To Image" or "base64 decode". This node pulls in the pack's PIL/Pillow stack (bundled with ComfyUI itself), so there's nothing extra to install and nothing model-related to download. If it doesn't appear after restart, check the console for a pack-level import error - that's the whole troubleshooting story.

    CategoryFair/image

    Inputs (1)

    NameTypeDefaultDescription
    stringSTRING

    Outputs (1)

    NameTypeDescription
    imageIMAGE