Image To Base64 Node
Your image as a base64 string, for the JSON APIs that won't take files
- image
- STRING
Some APIs don't want your image as a file upload - they want it as a base64 string buried inside a JSON payload. That's the whole reason the Image To Base64 Node exists. Feed it an IMAGE tensor and it returns a base64-encoded PNG as a plain string, ready to drop into a JSON body or glue into a prompt with String Replace Node.
It's one of the converter quartet in ComfyUI-HttpRequestNodes, the fork of felixszeto's ComfyUI-RequestNodes. The choice between this and its sibling Image To Blob Node is purely about the receiving end: raw bytes for octet-stream or multipart uploads, base64 string for JSON APIs that inline the image (think vision models, image-edit endpoints, anything that takes "image": "iVBORw0KGgo..."). The pack even has a Base64 To Audio Node on the audio side, so you can see the author likes the same trick for sound.
How it works
One input, image (IMAGE), one output - a STRING. The mechanism is straightforward: the tensor is converted to a PIL image, saved as PNG into memory, and the bytes are base64-encoded and decoded to UTF-8. Three practical notes:
- The string is raw base64 with no
data:prefix. If your API wantsdata:image/png;base64,...- and plenty do - you'll need to prepend that yourself, e.g. with a String Replace node or a concat node. - It's always PNG, same as the blob converter; there's no format picker.
- Base64 inflates size by ~33%, so a big generated image makes a long string. That's fine for JSON, but if size is the constraint, JPEG-at-source beats this node every time.
The output is a string, which also means you can see it, log it, or compare it - the round-trip path is Base64 To Audio Node for audio, and for images there's no Base64-to-image node in this pack, so keep the blob route (Blob To Image Node) in mind if you need data back in the graph.
Install
ComfyUI Manager → search ComfyUI-HttpRequestNodes → Install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/ahkimkoo/ComfyUI-HttpRequestNodes
pip install soundfile imageio imageio-ffmpeg
Category: RequestNode/Converters. PIL-only, no extra dependencies beyond ComfyUI core. The imageio/soundfile packages serve the pack's other converters. No models, no keys, nothing to download.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |