Nodes/ComfyUI/Generate Text
ComfyUI Node Runs on cloud

Generate Text

A real LLM living inside your ComfyUI graph

By Comfy-Org·Created 4 years ago·Updated 21 days ago· 121,575
Generate Text
  • clip
  • image
  • video
  • audio
  • generated_text
prompt
max_length512
sampling_mode
thinkingfalse
use_default_templatetrue

You can finally skip the copy-paste to ChatGPT. Generate Text (TextGenerate) runs a real LLM inside the graph: you feed it a CLIP that's actually a text-generation model, give it a prompt, and it hands back a finished string you can wire straight into your positive prompt box. It's ComfyUI's native "ask an LLM" node - no API key, no Ollama sidecar, nothing to install. It ships with core.

The name undersells what this unlocks. A workflow that writes its own prompts is the difference between typing "cyberpunk street, rain" and feeding a model a one-sentence scene description that comes back as a detailed, coherent prompt. People use it to brainstorm variations on a theme, to draft prompts for a model whose prompt style they don't know, to rephrase a tag soup into flowing prose, and (once you wire in the optional inputs) to caption an image or a video frame before feeding it elsewhere. The search alias is literally "gemma" - that's your first hint about what model it expects.

How it works

TextGenerate is a thin wrapper around three calls on your CLIP object: tokenize() turns your prompt (plus optional image/video/audio) into tokens, generate() runs the model with the sampler settings you chose, and decode() turns the output tokens back into text. The heavy lifting is all in the text encoder, not the node.

That last part matters more than it looks. Not every CLIP can generate. The regular SD/SDXL/Flux text encoders only embed text - they have no generate method and this node will simply fail or misbehave with them. You want a text-generation encoder like Gemma 3 (or a Qwen variant), loaded the normal way from the text_encoders folder with the standard CLIP Loader. That's why the node searches as "gemma": if you're hunting for this, you're hunting for Gemma.

The inputs that matter

  • prompt - your instruction to the LLM. Multiline, and it supports dynamic prompts, so you can use {seed}-style placeholders and loop over them.
  • sampling_mode - the dynamic combo that actually controls the model. Flip it to on and you get the full sampler drawer: temperature (0.7), top_k (64), top_p (0.95), min_p, repetition_penalty, seed, and presence_penalty. Flip it to off and it decodes greedily - deterministic, but blander. If you're getting stuck repeating loops, raise repetition_penalty.
  • max_length - cap on generated tokens. 512 is the default; raise it for long captions, lower it for one-liners. The node will stop there, mid-word or not.
  • image / video / audio - optional multimodal inputs. Gemma 3 is vision-capable, so you can feed a frame and say "describe this." Video is assumed to be 24 FPS and gets subsampled to 1 FPS internally.
  • thinking - toggles the model's reasoning mode if it supports one. Fun to try, slower, and the extra thinking text sometimes leaks into output - keep it off unless you're explicitly using it.
  • use_default_template - on by default, which uses the model's built-in system prompt. Turn it off if you've already wrapped your prompt in your own chat template.

The output is one thing: generated_text (STRING). Wire it to a CLIP Text Encode's text input, to an LTX-2 conditioning, or to any other text node downstream.

Common issues

Where people get burned: they connect their regular checkpoint's CLIP and get garbage or an error - you need a generation-capable encoder, and it's a second model in VRAM alongside whatever your diffusion model uses. On a smaller card, run a 4-bit quant of the LLM or generate once and cache the result instead of re-rolling on every queue. Also expect variation: LLM sampling is nondeterministic unless you set the seed, which is great for exploration and annoying when you wanted a stable baseline. Set seed, or leave sampling off, when you want reproducibility.

It's a recent addition to core, so if your ComfyUI is older than a few updates, refresh before hunting for it.

Categorytext

Inputs (9)

NameTypeDefaultDescription
clipCLIP
promptSTRING
max_lengthINT5121–32768
sampling_modeCOMBO2 options: [object Object], [object Object]
imageoptIMAGE
videooptIMAGEVideo frames as image batch. Assumed to be 24 FPS; subsampled to 1 FPS internally.
audiooptAUDIO
thinkingoptBOOLEANfalseOperate in thinking mode if the model supports it.
use_default_templateoptBOOLEANtrueUse the built in system prompt/template if the model has one.

Outputs (1)

NameTypeDescription
generated_textSTRING