Nodes/ComfyUI S4Tool Image/💀Image from Base64
ComfyUI Node

💀Image from Base64

Paste an encoded image straight into the graph

By S4MUEL-404·Created about a year ago·Updated 10 months ago· 4
💀Image from Base64
    • image
    • mask
    base64_string

    Images travel as base64 all the time - API responses, clipboard data, embedded previews, other tools' exports - and normally ComfyUI can't ingest any of that without you saving it to disk first. 💀Image from Base64 from the S4Tool-Image pack is the bridge: paste the base64 string into the node and out comes an IMAGE tensor (plus a mask derived from its alpha channel), ready to wire into the graph.

    The mechanism is straightforward decode-and-convert: the string is base64-decoded into bytes, opened with Pillow, normalized to RGB/RGBA (palette and grayscale formats are converted so the tensor is well-formed), and converted to a ComfyUI tensor. If the source had an alpha channel, the node also extracts it as a MASK output - white where opaque, black where transparent. That's a nice touch, because it means a transparent PNG arriving as base64 arrives as both the pixels and a ready-made alpha for masking work.

    Inputs and outputs

    • base64_string - the encoded image. It's a multiline field because long base64 is long. Paste the whole string; a data:image/png;base64,... prefix may or may not need stripping depending on where it came from.

    Outputs:

    • image - the decoded IMAGE tensor.
    • mask - a MASK from the alpha channel (fully white/opaque if the source had no transparency).

    Install

    Same pack, same routine:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/S4MUEL-404/ComfyUI-S4Tool-Image.git
    pip install -r ComfyUI-S4Tool-Image/requirements.txt
    

    Or ComfyUI Manager → search "S4Tool-Image" → Install → restart. No models - just Pillow.

    Gotchas

    • Decode failure returns a 64×64 black image - the node catches errors and returns a blank rather than crashing. If you get a black square, your string is malformed, truncated, or has whitespace/newlines that need cleaning.
    • The data:...;base64, prefix - if you copied a data URL, try both with and without the prefix. Pillow can't always sniff through it.
    • Paste a lot, check the size - base64 inflates bytes by ~33%; a 4K PNG's base64 is a big string and can get unwieldy in the widget. For anything large, a folder loader is usually saner.

    The sibling node 💀Image from Folder exists for when you have real files - this one is specifically for when the image is already a string in your clipboard or your API response, and you don't want to touch disk.

    Category💀S4Tool

    Inputs (1)

    NameTypeDefaultDescription
    base64_stringSTRING

    Outputs (2)

    NameTypeDescription
    imageIMAGE
    maskMASK