Nodes/comfyui_image_embeddings/Output Embedding to JSON
ComfyUI Node

Output Embedding to JSON

ComfyUI won't let you touch the numbers. This node does.

By baijunty·Created 8 months ago·Updated 3 months ago· 0
Output Embedding to JSON
  • vision_output
  • STRING
name

This is the node the whole pack is named after, and it fixes the most annoying thing about ComfyUI: the graph is great at showing you images and terrible at letting you do anything with the numbers. If you've ever wanted the actual embedding vector of an image - for a similarity search, a dataset, an API call to some external system - you usually hit a wall. The tensor is right there inside the workflow, but there's no clean way to get it out as text.

Output Embedding to JSON is that way out. You feed it a CLIP_VISION_OUTPUT and it hands you a plain JSON string containing the image embedding as a list of floats. Paste that into a file, a database, an HTTP request, whatever. No API key, no network call, no model download - it's pure serialization running on the machine you already have.

How it works

The node is disarmingly simple. A CLIP vision model (the image half of CLIP, the thing IP-Adapter and image-prompting flows use to turn a picture into a vector) outputs a dict that contains an image_embeds tensor. The node grabs that tensor, squeezes off the batch and channel dimensions, moves it to CPU, converts it to a plain Python list, and wraps it in JSON under a key you choose. That's the whole mechanism, and honestly that's why it's reliable.

You produce that input yourself: load a CLIP vision model (the CLIP Vision Loader style node, or the vision half of whatever adapter pack you're using) and run it through a CLIP Vision Encode node. The CLIP_VISION_OUTPUT that comes out of the encode is what this node eats.

The inputs that matter

  • vision_output - the CLIP vision output from an encode step. Required, and there's no substitute.
  • name - a plain string that becomes the JSON key. It's your label, so name it after the image or the batch this embedding came from. If you're collecting embeddings for multiple images, that key is how you tell them apart later.

Output is a single STRING - the JSON, e.g. {"my_image": [0.123, -0.456, ...]} with one float per dimension. Wire it into any node that accepts STRING: a text preview node so you can eyeball it, a file-save node, or a custom API call that ships it somewhere else.

Installing it

It ships in the comfyui_image_embeddings pack by baijunty. Easiest route is ComfyUI Manager - search for "image_embeddings" and install. Or clone it manually:

cd ComfyUI/custom_nodes
git clone https://github.com/baijunty/comfyui_image_embeddings

Restart ComfyUI. The pack's only declared Python dependency is imagehash; torch, torchvision, PIL and requests all come bundled with ComfyUI, so there's nothing heavy to pull for this node.

Where people get burned

The output is one giant line - a modern CLIP vision encoder produces hundreds or thousands of floats, all in a single JSON string. A text widget that truncates long lines will make it look like it "did nothing." Use a viewer that shows the full string, or just trust the wire.

Also, keep its job straight: this node serializes, it doesn't compute. If your embedding looks wrong, the problem is upstream in your CLIP vision encode, not here. And name is a single string, not a list - if you're batching many images through one workflow, you'll want a per-image key strategy rather than hoping the node guesses. It's a quiet utility, but it's the one node in this pack that does something you genuinely can't do with stock ComfyUI.

Categoryutils

Inputs (2)

NameTypeDefaultDescription
vision_outputCLIP_VISION_OUTPUT
nameSTRING

Outputs (1)

NameTypeDescription
STRINGSTRING