LLM_Detokenize
Turn a pile of token IDs back into readable text
- LLM
- STRING
LLMs don't read words; they read token IDs - integers that map to pieces of text through the model's tokenizer. LLM_Detokenize is the reverse function: feed it a list of those integer IDs, and it hands you back the text they spell out, as a STRING. It's the mirror image of this pack's LLM_Tokenize node, and it's most useful when you're doing low-level token surgery rather than plain prompt-and-reply generation.
That framing matters, because this is a utility node, not a workflow backbone. You reach for it when you've been fiddling with raw tokens - sampling one from a model, or building a token sequence by hand - and want to check what the model actually "heard" or is about to "say." Think of it as the debug viewer for the token stream.
Inputs and output
- LLM - the loaded model, from any of the pack's loaders. You need it because tokenization is model-specific: every tokenizer has its own vocabulary, so the same ID means different things in different models. The node uses your model's own tokenizer to decode.
- tokens - an
INTlist of token IDs, defaulting to[0]. In practice this comes fromLLM_Tokenize's output or fromLLM_Sample. The schema treats it as a single-value list, and ComfyUI's list wiring handles the rest.
The output is STRING - the decoded text. Which, like every string in this pack, is invisible unless you connect it to a display node like ShowText from ComfyUI-Custom-Scripts.
Why you'd actually build that graph
A realistic minimal flow: LLM_Tokenize (text in → token IDs out) → LLM_Detokenize (token IDs in → text out). Round-tripping text through tokens and back looks pointless until you realize it's the foundation for everything else in the pack - LLM_Eval processes tokens into the model's context, LLM_Sample picks the next token, and LLM_Detokenize is how you see any of that in human-readable form. It's the same reason a tokenizer exists in every other LLM tooling stack: you need to see the units you're manipulating.
One practical gotcha: tokenization isn't lossless in the way you'd hope. Whitespace is often a separate token, words split mid-morpheme, and decoding a sequence that was built out of order (or from a different model's tokenizer) can produce garbled text. If a round-trip comes back with stray spaces or mangled words, that's normal tokenizer behavior, not a broken node.
Install
It ships with the pack, so the steps are the shared ones - ComfyUI Manager search "ComfyUI-Llama", or:
cd ComfyUI/custom_nodes
git clone https://github.com/daniel-lewis-ab/ComfyUI-Llama
with pip install llama-cpp-python on manual installs. Models live in ComfyUI/custom_nodes/ComfyUI-Llama/models, restart, Ctrl+F5, nodes under the LLM menu.
Is this the node you'll reach for every day? Probably not - most people want text out of Call LLM nodes, and those already return strings. But the moment you start experimenting with the token-level nodes in this pack, LLM_Detokenize becomes the thing that tells you whether your experiment worked. It's the "print()" of the pack.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| LLM | LLM | — | |
| tokens | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |