Nodes/NH-Nodes/Value Match Index (NH)
ComfyUI Node

Value Match Index (NH)

The lookup node your switches are missing

By jetthuangai·Created 5 months ago·Updated 21 days ago· 6
Value Match Index (NH)
  • input
  • index
compare_modein
value_count5
no_match_index-1
multi_match_index-1
value_1
value_2
value_3
value_4
value_5
value_6
value_7
value_8
value_9
value_10
value_11
value_12
value_13
value_14
value_15
value_16
value_17
value_18
value_19
value_20
value_21
value_22
value_23
value_24
value_25
value_26
value_27
value_28
value_29
value_30
value_31
value_32
value_33
value_34
value_35
value_36
value_37
value_38
value_39
value_40
value_41
value_42
value_43
value_44
value_45
value_46
value_47
value_48
value_49
value_50
value_51
value_52
value_53
value_54
value_55
value_56
value_57
value_58
value_59
value_60
value_61
value_62
value_63
value_64

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. portrait matches portrait 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.

CategoryNH-Nodes/Logic

Inputs (69)

NameTypeDefaultDescription
input*
compare_modeCOMBOin2 options: in, is
value_countINT51–64
no_match_indexINT-1-9999–9999
multi_match_indexINT-1-9999–9999
value_1optSTRING
value_2optSTRING
value_3optSTRING
value_4optSTRING
value_5optSTRING
value_6optSTRING
value_7optSTRING
value_8optSTRING
value_9optSTRING
value_10optSTRING
value_11optSTRING
value_12optSTRING
value_13optSTRING
value_14optSTRING
value_15optSTRING
value_16optSTRING
value_17optSTRING
value_18optSTRING
value_19optSTRING
value_20optSTRING
value_21optSTRING
value_22optSTRING
value_23optSTRING
value_24optSTRING
value_25optSTRING
value_26optSTRING
value_27optSTRING
value_28optSTRING
value_29optSTRING
value_30optSTRING
value_31optSTRING
value_32optSTRING
value_33optSTRING
value_34optSTRING
value_35optSTRING
value_36optSTRING
value_37optSTRING
value_38optSTRING
value_39optSTRING
value_40optSTRING
value_41optSTRING
value_42optSTRING
value_43optSTRING
value_44optSTRING
value_45optSTRING
value_46optSTRING
value_47optSTRING
value_48optSTRING
value_49optSTRING
value_50optSTRING
value_51optSTRING
value_52optSTRING
value_53optSTRING
value_54optSTRING
value_55optSTRING
value_56optSTRING
value_57optSTRING
value_58optSTRING
value_59optSTRING
value_60optSTRING
value_61optSTRING
value_62optSTRING
value_63optSTRING
value_64optSTRING

Outputs (1)

NameTypeDescription
indexINT