Text Index (NH)
Pick the Nth prompt out of a stack, and stop when there's nothing to pick
- text
When you've got a stack of prompts - one per shot, one per variation, one per folder - the obvious move is an index: "give me the third one." Text Index (NH) does exactly that, and it's careful about the edge cases in a way that makes it genuinely safer than a naive pick.
You tell it how many slots you're using with text_count (default 5, max 64) and which one you want with index. The node exposes text_1 through text_N multiline inputs and returns the one at index as a single STRING. It's one-based, because people - and ComfyUI - think in one-based when they're counting prompts, so slot 1 is text_1, not slot 0. That's the first thing to double-check if the "wrong" prompt comes out: you're off by one from whatever system you're used to.
The interesting part is what happens at the boundaries. This isn't a node that returns None or an empty string and lets garbage flow downstream. If the index is out of range (say index 5 but text_count 3), or the selected slot is empty, the node returns an execution blocker - a special value that tells ComfyUI to skip everything downstream of it rather than run with a bogus prompt. So a workflow asking for prompt 7 of a 5-prompt stack doesn't generate a nonsense image; it just doesn't generate that branch at all. That's a design choice worth appreciating: an explicit "stop here" beats a silent empty prompt every time.
Why you'd use it
The natural consumer is a batch or animation workflow where a counter steps index and each step samples a different prompt - feed the output into a CLIP encoder, same as any prompt. It also pairs beautifully with a Switch N or a Random Choice upstream if you want to choose which index to read rather than hardcode it. The text_count cap of 64 keeps it honest for big stacks, and since the slots are multiline, each prompt can itself be a multi-line block.
Install
It's part of NH-Nodes:
- ComfyUI Manager → search NH-Nodes → install → restart ComfyUI. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
Then restart ComfyUI.
No models or heavy deps - plain string plumbing.
Common issues
The two failure modes are both "nothing comes out," and they're distinguishable: an out-of-range index or an empty slot blocks execution downstream (the graph just stops there), while a valid index with a filled slot always produces text. If a branch silently produces no image, your first check is index vs text_count. And the off-by-one: if the prompt "one before the one I picked" shows up, remember it's 1-based. Keep index visible and you'll spot either in a glance.
Inputs (66)
| Name | Type | Default | Description |
|---|---|---|---|
| index | INT | 11–64 | — |
| text_count | INT | 51–64 | — |
| text_1opt | STRING | — | |
| text_2opt | STRING | — | |
| text_3opt | STRING | — | |
| text_4opt | STRING | — | |
| text_5opt | STRING | — | |
| text_6opt | STRING | — | |
| text_7opt | STRING | — | |
| text_8opt | STRING | — | |
| text_9opt | STRING | — | |
| text_10opt | STRING | — | |
| text_11opt | STRING | — | |
| text_12opt | STRING | — | |
| text_13opt | STRING | — | |
| text_14opt | STRING | — | |
| text_15opt | STRING | — | |
| text_16opt | STRING | — | |
| text_17opt | STRING | — | |
| text_18opt | STRING | — | |
| text_19opt | STRING | — | |
| text_20opt | STRING | — | |
| text_21opt | STRING | — | |
| text_22opt | STRING | — | |
| text_23opt | STRING | — | |
| text_24opt | STRING | — | |
| text_25opt | STRING | — | |
| text_26opt | STRING | — | |
| text_27opt | STRING | — | |
| text_28opt | STRING | — | |
| text_29opt | STRING | — | |
| text_30opt | STRING | — | |
| text_31opt | STRING | — | |
| text_32opt | STRING | — | |
| text_33opt | STRING | — | |
| text_34opt | STRING | — | |
| text_35opt | STRING | — | |
| text_36opt | STRING | — | |
| text_37opt | STRING | — | |
| text_38opt | STRING | — | |
| text_39opt | STRING | — | |
| text_40opt | STRING | — | |
| text_41opt | STRING | — | |
| text_42opt | STRING | — | |
| text_43opt | STRING | — | |
| text_44opt | STRING | — | |
| text_45opt | STRING | — | |
| text_46opt | STRING | — | |
| text_47opt | STRING | — | |
| text_48opt | STRING | — | |
| text_49opt | STRING | — | |
| text_50opt | STRING | — | |
| text_51opt | STRING | — | |
| text_52opt | STRING | — | |
| text_53opt | STRING | — | |
| text_54opt | STRING | — | |
| text_55opt | STRING | — | |
| text_56opt | STRING | — | |
| text_57opt | STRING | — | |
| text_58opt | STRING | — | |
| text_59opt | STRING | — | |
| text_60opt | STRING | — | |
| text_61opt | STRING | — | |
| text_62opt | STRING | — | |
| text_63opt | STRING | — | |
| text_64opt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |