Load Image From Base64
Feed images to ComfyUI's API as base64
- IMAGE
- MASK
The stock LoadImage node has a dirty secret: it doesn't read an image, it reads a filename from your ComfyUI/input folder. That's fine when you're clicking around in the UI, but the moment you're driving ComfyUI through its HTTP API from your own app, it means every image has to be written to disk on the server first before the graph can touch it. Load Image From Base64 exists to cut that step out - you paste the base64 payload straight into the workflow JSON and ComfyUI decodes it in memory. The name is only half a lie: it doesn't call any API and needs no key, it just saves you the file round-trip.
What it actually is
One tiny node by glowcone, part of the comfyui-base64-to-image pack. One input, two outputs, no models, no settings, no ceremony. It exists for exactly one scenario: a headless or scripted pipeline where the image arrives over the wire instead of from your hard drive. People genuinely hit this wall - "how do I send images to the ComfyUI API" is a recurring question in r/StableDiffusion, and the usual workaround is either writing to input/ yourself or fighting a bigger, fiddlier nodes pack.
How it works
The mechanism is about as honest as it gets. Your data string goes through base64.b64decode, becomes a numpy byte array, and gets handed to OpenCV's cv2.imdecode with IMREAD_UNCHANGED. That decode does the real work: it figures out the format and whether there's an alpha channel. If there are four channels, channel 3 becomes the MASK output (as a 0–1 float tensor, exactly like core LoadImage derives its mask); if there's no alpha, you get an all-ones mask instead, meaning "fully opaque everywhere." The remaining channels get converted from BGR/RGBA to RGB, normalized to 0–1, and come out as the IMAGE tensor.
Nothing here is exotic - cv2, PIL, numpy and torch are all already inside a stock ComfyUI install. There's no requirements.txt doing anything, no model download, nothing to babysit.
The one input that matters
data(STRING) - the base64 image payload. That's the whole interface.
And here's the trap the pack's own naming sets for you: the title says Base64 URI, but the code does a bare base64.b64decode. Feed it a full data:image/png;base64,... URI and the data:image/png;base64 prefix letters survive the decode and corrupt the bytes - you get a red error node, not an image. Pass the raw base64 payload (the README's example is exactly that: a string starting iVBOR...). A quick sanity check: python -c "import base64; base64.b64decode(open('test.png','rb').read())" - no, simpler - just keep the string between the comma and the end of a proper data URI.
Outputs and where they go
IMAGE- a standard image tensor. Wires into anything a core Load Image output does: a VAE encode, an img2img pipeline, a ControlNet reference, a face-fix pass.MASK- the alpha channel as a mask tensor, or an all-ones mask for opaque images. Feed it wherever a mask is expected - inpainting, compositing, background-removal post-processing.
Installing it
Easiest path is ComfyUI Manager: search for "Load Image From Base64 URI" (the pack's display title) and hit install, then restart. Or clone it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/glowcone/comfyui-base64-to-image
then restart ComfyUI. That's it - no model files, no pip install, no dependency conflicts waiting for you.
Where people get burned
Bad input crashes ungracefully. cv2.imdecode returns nothing on junk, and the node doesn't catch it, so a truncated or mangled base64 string shows up as a hard node error. Test with the README's sample string before you blame your pipeline.
Also watch the size math. Base64 inflates binary by about 33%, and you're now stuffing that string into a JSON prompt. A 4K PNG can balloon your API payload to tens of megabytes. Encode JPEGs or smaller images, or downscale before base64-encoding, and your request stays snappy.
If your MASK comes out all white, that's not a bug - the source image genuinely has no alpha channel. Want transparency? Export the PNG with alpha before encoding.
Verdict
For local, click-around workflows, keep using the built-in LoadImage - this node adds nothing there. But for a script, a web app, or any API pipeline that needs to move an image into ComfyUI without touching the server's disk, it's the smallest, most dependency-free way to do it. One input, one job, done.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| data | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |