Nodes/ComfyUI 1hewNodes/Text Match Value
ComfyUI Node

Text Match Value

A lookup table that lives inside your workflow

By 1hew·Created about a year ago·Updated 7 days ago· 33
Text Match Value
    • value
    text_multiline
    text_single

    Text Match Value is a tiny key→value lookup you can paste right into the graph. You give it a block of key: value lines and a single query string, and it hands back the value whose key matches - no if/else chains, no String Switch node, no Python. If you've ever found yourself building a four-node tower just to pick between two CFG scales, this is the node that collapses it to one.

    The use case is automation: mapping mode names to settings, model names to sampler presets, or turning a hand-typed tag into a batch of parameters. Say you have a workflow that can run in quick or high_quality mode. Put quick: 20\nhigh_quality: 40 in the multiline input, feed whichever mode you want as the query, and the value output drives your step count. Change the table once, and every downstream node follows.

    How it actually works

    It's a small parser, and the source is worth a skim because the matching rules surprise people. Each non-empty line is split at the first : (it also accepts the fullwidth ), then both key and query get stripped and lowercased. Exact match first, then prefix match as a fallback, then an empty string if nothing fits. So MODEL and model both match model: 0.9.

    One genuinely handy detail: keys and values wrapped in {braces} get unwrapped. That's your escape hatch for values that contain a colon of their own - {strength: 0.5} parses as a single value instead of splitting on the colon.

    Since v3.15.1 the return value is auto-typed, which is what makes it wire into anything: true/false come back as booleans, integers as INT, floats as FLOAT, and everything else as a plain string. The output is typed * (wildcard), so ComfyUI will happily plug it into STRING, INT, FLOAT, or BOOL inputs without conversion nodes.

    The two inputs that matter

    • text_multiline - your lookup table. One key: value per line; blank lines are skipped.
    • text_single - the query. Not multiline, and it's the only thing you're likely to change while experimenting.

    The single output is value (type *). That's it. There's nothing else to configure, which is the point.

    Installing it

    It ships in ComfyUI 1hewNodes, a grab-bag utility pack by a prolific developer (wangyihe1127) that covers image processing, masks, resizing, batching, and text. ComfyUI Manager has it - search "ComfyUI-1hewNodes" - or clone it manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/1hew/ComfyUI-1hewNodes
    

    Then restart ComfyUI. Note the pack is built on ComfyUI's newer declarative node API (comfy_api.latest), so keep ComfyUI reasonably current - an old install may not register its nodes at all.

    Where people get burned

    The big one: no match is not an error. If the query doesn't match anything you get back an empty string, and whatever downstream node is consuming it quietly does something undefined with "". That's actually useful as a signal - check whether value is empty and you've got a free "did the lookup succeed" flag - but if you expect a crash or a warning, you'll be waiting.

    The prefix-match fallback is the other gotcha. A query of quick matches quick: 20 and any key that merely starts with quick, like quickest: 5. With a long table, order matters more than you'd think. When two keys collide, the first one in the file wins.

    The pack's requirements.txt is heavy on paper - opencv, scikit-image, ultralytics, rembg - but almost all of that is for the pack's image/video/detection nodes. This node is pure Python stdlib plus the ComfyUI API. If the install's dependency resolution complains, it's some other node in the pack pulling the weight, not this one.

    Category1hewNodes/logic

    Inputs (2)

    NameTypeDefaultDescription
    text_multilineSTRING
    text_singleSTRING

    Outputs (1)

    NameTypeDescription
    value*