Nodes/ComfyUI-DAAM/CLIP Text Encode (With Tokens)
ComfyUI Node

CLIP Text Encode (With Tokens)

The CLIP Encode That Also Hands You the Tokens

By nisaruj·Created about a year ago·Updated 11 months ago· 54
CLIP Text Encode (With Tokens)
  • clip
  • CONDITIONING
  • TOKENS
text

The built-in CLIP Text Encode does its job and throws away the evidence: it turns your prompt into a CONDITIONING tensor and the tokenized prompt is gone. This node is the same encode, but it keeps the receipt. Its whole reason to exist is a second output - TOKENS, the tokenized prompt - which the other nodes in the ComfyUI-DAAM pack need to map attention maps back to your words.

What it is, honestly

A drop-in replacement for the core CLIPTextEncode. Same inputs (text, multiline, and clip), same primary output (CONDITIONING), same behavior - the README says "identical," and the source backs that up: it calls clip.tokenize() and clip.encode_from_tokens() through the exact same code path. The dynamic-prompts syntax (__wildcard__) works here too. The only addition is the TOKENS output: the raw token list after tokenization.

So there's no magic and no downside - but there's also no reason to use it unless you're building a DAAM workflow. If you're not analyzing attention, the built-in node is fewer moving parts. Use this one when you want the attention analysis, and it's not optional: DAAMAnalyzer and DAAMPreviewImage both take a tokens input, and there's no other node in the graph that produces that data type.

How to wire it

Encode your positive prompt with this node, run the CONDITIONING output into KSamplerDAAM's positive input, and run the TOKENS output into the analyzer. The important rule: the tokens you hand the analyzer must come from the same encode that produced the conditioning the sampler actually used - otherwise the heatmaps describe a different prompt than your tokens do, and the word-matching silently misses.

Also encode your negative prompt with this node if you want to analyze negative-prompt words. KSamplerDAAM records neg_heatmaps separately, so there's real value in a second instance of this node on the negative side.

Install

It ships with the rest of the pack - no separate install. ComfyUI Manager (search ComfyUI-DAAM), or:

cd ComfyUI/custom_nodes
git clone https://github.com/nisaruj/comfyui-daam.git
cd comfyui-daam
python3 -s -m pip install -r requirements.txt

Restart ComfyUI. The only dependency is matplotlib, and there are no model downloads. You'll find it under the daam-nodes category in the add-node menu. It's a utility node with a single job - the kind you place once at the start of a debug workflow and forget about.

Categorydaam-nodes

Inputs (2)

NameTypeDefaultDescription
textSTRINGThe text to be encoded.
clipCLIPThe CLIP model used for encoding the text.

Outputs (2)

NameTypeDescription
CONDITIONINGCONDITIONINGA conditioning containing the embedded text used to guide the diffusion model.
TOKENSTOKENSList of tokens after tokenization.