Value Match Index (NH)
The lookup node your switches are missing
- input
- index
Value Match Index (NH) is the glue between ComfyUI's two worlds: strings and numbers. It takes an incoming value, compares it against a list of things you've configured, and spits out the index of whatever matched. One number out, and that number is exactly the kind of thing the pack's switches and indexed loaders eat for breakfast.
Think of the uses: a filename that contains portrait should route to one branch, landscape to another. A category label from an API response should pick VAE slot 2. A batch_12 filename should select prompt 3 from a list. Every one of those is "map this string to an index," and this node is that mapping in a box.
How it works
You give it input (any type - it's coerced to a string) and up to 64 configured value_N slots (default 5). Two modes, chosen by compare_mode:
- in (default) - substring match: the configured value just needs to appear inside the input.
portraitmatchesportrait with rim light. Loose and forgiving, which is usually what you want with filenames. - is - exact equality: the whole input must equal the value, byte for byte. Case-sensitive, strict.
Empty value slots are skipped, so you don't have to fill all 64. The output is one INT, index, and it follows clear rules:
- Exactly one match → that slot's 1-based index.
- No match → no_match_index (default
-1). - Two or more matches → multi_match_index (default
-1).
Those last two are your sentinels, and they're why this node is genuinely useful rather than a toy: you decide what "nothing matched" means instead of hoping. Default to -1 for both and feed the result into a switch whose default case handles the miss.
The traps
in is substring, and it's case-sensitive. The value dog will match doggy, and Dog won't match dog. If exactness matters, flip to is; if case matters, normalize your input upstream with the pack's String Operations (NH). Also note the "first match wins unless there are two" rule - if dog and doggy are both configured and the input contains doggy, you get multi_match_index, not the first one. With substring matching, overlapping values are a real footgun.
Where it shines
The classic loop: Value Match Index → Switch N (NH). The string decides the branch, the switch does the routing. It also feeds naturally into the pack's indexed loaders (Load VAE Index, Load LoRA Model Index) - a filename containing anime picks the anime LoRA slot, realistic picks another - and into Text Index for pulling the matching line from a list.
It's a small node with a deceptively big role: it's the missing "lookup table" that lets a workflow react to data instead of manual fiddling. If you've ever wished a switch could decide for itself, this is the node that makes it possible.
Install
Ships in NH-Nodes. ComfyUI Manager → search NH-Nodes → install → restart:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
Pure logic, no models, no downloads. Restart ComfyUI after installing and refresh the page if the node looks cached.
Inputs (69)
| Name | Type | Default | Description |
|---|---|---|---|
| input | * | — | |
| compare_mode | COMBO | in | 2 options: in, is |
| value_count | INT | 51–64 | — |
| no_match_index | INT | -1-9999–9999 | — |
| multi_match_index | INT | -1-9999–9999 | — |
| value_1opt | STRING | — | |
| value_2opt | STRING | — | |
| value_3opt | STRING | — | |
| value_4opt | STRING | — | |
| value_5opt | STRING | — | |
| value_6opt | STRING | — | |
| value_7opt | STRING | — | |
| value_8opt | STRING | — | |
| value_9opt | STRING | — | |
| value_10opt | STRING | — | |
| value_11opt | STRING | — | |
| value_12opt | STRING | — | |
| value_13opt | STRING | — | |
| value_14opt | STRING | — | |
| value_15opt | STRING | — | |
| value_16opt | STRING | — | |
| value_17opt | STRING | — | |
| value_18opt | STRING | — | |
| value_19opt | STRING | — | |
| value_20opt | STRING | — | |
| value_21opt | STRING | — | |
| value_22opt | STRING | — | |
| value_23opt | STRING | — | |
| value_24opt | STRING | — | |
| value_25opt | STRING | — | |
| value_26opt | STRING | — | |
| value_27opt | STRING | — | |
| value_28opt | STRING | — | |
| value_29opt | STRING | — | |
| value_30opt | STRING | — | |
| value_31opt | STRING | — | |
| value_32opt | STRING | — | |
| value_33opt | STRING | — | |
| value_34opt | STRING | — | |
| value_35opt | STRING | — | |
| value_36opt | STRING | — | |
| value_37opt | STRING | — | |
| value_38opt | STRING | — | |
| value_39opt | STRING | — | |
| value_40opt | STRING | — | |
| value_41opt | STRING | — | |
| value_42opt | STRING | — | |
| value_43opt | STRING | — | |
| value_44opt | STRING | — | |
| value_45opt | STRING | — | |
| value_46opt | STRING | — | |
| value_47opt | STRING | — | |
| value_48opt | STRING | — | |
| value_49opt | STRING | — | |
| value_50opt | STRING | — | |
| value_51opt | STRING | — | |
| value_52opt | STRING | — | |
| value_53opt | STRING | — | |
| value_54opt | STRING | — | |
| value_55opt | STRING | — | |
| value_56opt | STRING | — | |
| value_57opt | STRING | — | |
| value_58opt | STRING | — | |
| value_59opt | STRING | — | |
| value_60opt | STRING | — | |
| value_61opt | STRING | — | |
| value_62opt | STRING | — | |
| value_63opt | STRING | — | |
| value_64opt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| index | INT | — |