Nodes/Template Vars/CLIP Text Encode With Template Variables
ComfyUI Node

CLIP Text Encode With Template Variables

Apply your variables and encode in a single box

By boobkake22·Created 3 months ago·Updated 2 months ago· 0
CLIP Text Encode With Template Variables
  • clip
  • variables
  • conditioning
  • preview
text

This is the pack's convenience node: it replaces the two-node chain of "Apply Template Variables → CLIP Text Encode" with a single box that does the rendering and the conditioning in one go. You plug in your CLIP model, type a prompt with {placeholders}, connect a TEMPLATE_VARS map, and out comes conditioning - ready for a sampler.

Why bother, when you could just use the plain Apply node plus ComfyUI's built-in CLIP Text Encode? Because this node is opinionated in a useful way. It keeps the UI small and it fails loudly instead of silently rendering garbage. If you're the kind of person who reuses workflows, that strictness is the point - it catches a missing variable before you've queued 50 images with {location} literally sitting in the prompt.

How it works

Two things happen inside: it renders the template (same placeholder substitution as Apply Template Variables), then it tokenizes the rendered string and encodes it into CONDITIONING with your CLIP. So the encoding always sees the final, substituted prompt - there's no way for a stale {name} to sneak into the sampler.

The inputs:

  • clip - your CLIP model, wired from whatever loader your checkpoint needs.
  • text - the prompt template. Blank by default, with text as the placeholder hint, so you're never fighting a sample prompt.
  • variables (optional) - the TEMPLATE_VARS map from the pack's creator nodes.

Outputs:

  • conditioning - the encoded prompt, wired into your sampler's positive (or negative) input.
  • preview - the rendered prompt text, after substitution. It's a normal string output you don't have to wire anywhere; connect it to a text display node if you want to eyeball what actually got encoded.

The rules, and the one thing it won't do

Where this node differs from Apply Template Variables is that it's strict on purpose:

  • placeholder style is fixed to {name} - no {{name}} or $name here
  • unmatched braces raise an error
  • missing variables raise an error - there is no keep mode, no silent passthrough

It also doesn't support the inline default syntax ({name|someone}) that Apply does; the placeholder has to be a clean name. If you want defaults, missing-keep behavior, or another placeholder style, use Apply Template Variables and feed its string output into a regular CLIP Text Encode - the pack's own README says exactly that. Think of this node as the strict fast path and Apply as the flexible one. Most workflows start on the flexible one and graduate to this once the variables are stable.

A note for the pre-2026 ComfyUI heads: conditioning is the same wire type the built-in node emits, and preview is plain text, so this drops into existing graphs without changing anything downstream.

Installation

Same pack as the rest - this is one of six nodes in boobkake22/ComfyUI-TemplateVars, and it has zero extra dependencies and no model files. Install via ComfyUI Manager (search "Template Vars") or cd ComfyUI/custom_nodes && git clone https://github.com/boobkake22/ComfyUI-TemplateVars, then restart. The whole pack appears under Template Vars.

If a variable won't render, the error message names it - that's the loud failure in action. And remember, unlike the raw text box in the built-in encoder, this node's text field won't trigger ComfyUI's dynamic prompt/wildcard expansion, so your braces stay exactly as you typed them.

CategoryTemplate Vars

Inputs (3)

NameTypeDefaultDescription
clipCLIP
textSTRING
variablesoptTEMPLATE_VARS

Outputs (2)

NameTypeDescription
conditioningCONDITIONING
previewSTRING