Nodes/NIX ComfyUI Plugin/NIX_StringMatcher
ComfyUI Node

NIX_StringMatcher

Exact-match one string against up to 32 options and get back the winning index

By J-ChenX·Created about a year ago·Updated about a year ago· 2
NIX_StringMatcher
    • index
    ◄string_1►
    ◄string_2►
    ◄judge_string►
    ◄inputcount2►
    ◄string_3►
    ◄string_4►
    ◄string_5►
    ◄string_6►
    ◄string_7►
    ◄string_8►
    ◄string_9►
    ◄string_10►
    ◄string_11►
    ◄string_12►
    ◄string_13►
    ◄string_14►
    ◄string_15►
    ◄string_16►
    ◄string_17►
    ◄string_18►
    ◄string_19►
    ◄string_20►
    ◄string_21►
    ◄string_22►
    ◄string_23►
    ◄string_24►
    ◄string_25►
    ◄string_26►
    ◄string_27►
    ◄string_28►
    ◄string_29►
    ◄string_30►
    ◄string_31►
    ◄string_32►

    NIX_StringMatcher is a lookup table for strings. You give it a list of candidate strings and a judge_string to compare against, and it returns the index of the first candidate that matches exactly - or -1 if nothing matches. If you've ever wanted to branch a workflow on "what category did the model just return?", this is the node that turns a string into a number you can switch on.

    It's part of the NIX pack, which is a small, dependency-light utility collection (numpy + Pillow, no models). One install gets you this plus the pack's crop, rotate, and save nodes.

    How it works

    Required inputs: string_1, string_2, and judge_string. An inputcount dial (default 2, up to 32) controls how many candidates participate, and the node dynamically adds string_3 through string_32 inputs to match. The dynamic inputs come from a small web extension that ships with the pack - if you don't see string_3+ on the node, update ComfyUI's frontend or check that the pack's web/ folder is present.

    The logic is dead simple:

    • Normalize everything to strings (it won't crash on numbers, it just stringifies them).
    • Compare judge_string against string_1, then string_2, then string_3, ... in order.
    • Return the index (INT) of the first exact match - 1-based, so string_1 → 1.
    • No match → -1.

    Two details that matter:

    • Exact match. Case-sensitive, no substring, no fuzzy, no wildcard. "Cat" does not match "cat".
    • First match wins. If two candidates are identical, the lower index wins.

    Where it slots in

    The classic combo: an LLM or prompt node returns a free-form string, you want to route on it. NIX_StringMatcher turns "the model said landscape" into a clean integer, and that integer feeds straight into NIX_SwitchAnything - index in, the right branch out. Same idea for filenames, model names, or any classification result you need to act on.

    The -1 case is the one to design for: a judge string that matches none of your candidates silently falls through. Route it to a default branch rather than assuming it can't happen.

    Getting it installed

    • ComfyUI Manager: search "NIX" / "NIX ComfyUI Plugin", or Install Custom Nodes → Git URL → https://github.com/J-ChenX/ComfyUI-NIX. Restart after.
    • By hand:
      cd ComfyUI/custom_nodes
      git clone https://github.com/J-ChenX/ComfyUI-NIX
      
      Restart ComfyUI. Under the "NIX" category.

    Things that will bite you

    • Exact, case-sensitive matching. If your judge string has trailing whitespace or a different case, you get -1 and no explanation. Normalize upstream if you can.
    • inputcount clamps to 2–32. It silently bounds itself; don't rely on it erroring if you set it out of range.
    • The dynamic inputs need the web folder. On a bare install that skips web/, only string_1 and string_2 may be available.
    • Quiet pack. Essentially no community footprint for NIX as of mid-2026 - no copied workflows to lean on, but the matching logic is a short readable block if you ever doubt the order it checks in.
    CategoryNIX

    Inputs (34)

    NameTypeDefaultDescription
    string_1STRING—
    string_2STRING—
    judge_stringSTRING—
    inputcountoptINT22–32—
    string_3optSTRING—
    string_4optSTRING—
    string_5optSTRING—
    string_6optSTRING—
    string_7optSTRING—
    string_8optSTRING—
    string_9optSTRING—
    string_10optSTRING—
    string_11optSTRING—
    string_12optSTRING—
    string_13optSTRING—
    string_14optSTRING—
    string_15optSTRING—
    string_16optSTRING—
    string_17optSTRING—
    string_18optSTRING—
    string_19optSTRING—
    string_20optSTRING—
    string_21optSTRING—
    string_22optSTRING—
    string_23optSTRING—
    string_24optSTRING—
    string_25optSTRING—
    string_26optSTRING—
    string_27optSTRING—
    string_28optSTRING—
    string_29optSTRING—
    string_30optSTRING—
    string_31optSTRING—
    string_32optSTRING—

    Outputs (1)

    NameTypeDescription
    indexINT—