JSON Image Encoder (Soze)
Image to text — a standalone encoder for JSON payloads
- image
- encoded
Sometimes you don't want the key bundled with the image - you just need the encoded image as a bare string you can plug into a value socket, a text file, or any node that eats text. JSON Image Encoder (Soze) is that standalone piece: IMAGE in, one STRING out. No JSON chain involved. It's the same encoding core the chain's Image Pair uses, stripped of the name and chain_in ceremony.
You'll reach for it when the image needs to travel as text but the structure around it is already handled elsewhere - say, feeding an encoded image into a JSON Chain String Pair's value input, or into any API/text node that expects a data URI or file path on its own. It encodes the first frame of the batch; the array variant exists if you need all frames.
How it works
Identical mechanics to the Image Pair's encoder. data_uri mode produces data:image/<fmt>;base64,... (self-contained, but big - a 1MP PNG is ~1.5 MB of base64). filepath mode saves the image to disk and returns the absolute path (tiny, but the output only means something on a machine that can see that file). format picks png/jpeg/webp; jpeg_quality (default 95) only matters for jpeg and webp; save_path and append_suffix control filepath-mode naming, with an extension added automatically if you omit it.
Inputs and outputs
- image - required IMAGE input (forced). First frame is used.
- mode -
data_uriorfilepath. - format -
png,jpeg, orwebp. - jpeg_quality, save_path, append_suffix - optional.
Output: encoded, a single STRING - the data URI or the file path.
Installing it
Part of the Soze pack:
cd ComfyUI/custom_nodes
git clone https://github.com/SozeInc/ComfyUI_Soze.git
pip install -r ComfyUI_Soze/requirements.txt
Restart ComfyUI, or search ComfyUI_Soze in ComfyUI Manager.
Gotchas
The usual suspects: watch payload size in data_uri mode (JPEG + lower quality if the API is strict), and remember it's the first frame only. One pleasant surprise - the decoder exists on the other end, and it's permissive: JSON Image Decoder accepts this encoder's output (data URI or path) as well as URLs, JSON arrays, and newline lists, so an encode→decode round-trip through text is fully supported if you ever need to serialize an image mid-graph.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mode | COMBO | data_uri | 2 options: data_uri, filepath |
| format | COMBO | png | 3 options: png, jpeg, webp |
| jpeg_qualityopt | INT | 951–100 | Only used for jpeg / webp. |
| save_pathopt | STRING | filepath mode: target path (relative to ComfyUI output dir, or absolute). Extension is added if missing. | |
| append_suffixopt | BOOLEAN | true | filepath mode: append _00001 if the target already exists. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| encoded | STRING | — |