ComfyUI Node

casefold

The lowercase that makes 'ß' match 'ss'

By StableLlama·Created about a year ago·Updated 4 days ago· 48
casefold
    • STRING
    string

    You're comparing two strings in ComfyUI and getting False when they're clearly the same word. Classic. ComfyUI is brutal about case - "berlin" and "Berlin" are different strings, full stop. This node is the fix, and it's a better fix than the obvious one.

    What it actually does

    casefold is a thin wrapper over Python's str.casefold(), and the one-line version is: it's lowercase, but smarter. Plain .lower() misses Unicode edge cases; casefold handles the folding that makes case-insensitive comparison actually work across languages. The example everyone uses is German - "Straße".casefold() becomes "strasse", so it compares equal to "STRASSE". .lower() doesn't do that. It's the difference between "good enough for English" and "correct".

    You get one input, string, and one STRING output. That's the entire node - no options to fiddle, nothing to misconfigure.

    Why you'd bother

    Anytime two strings come from different places and you need them to match. Tags scraped from a file versus tags you typed. A checkpoint name that arrived capitalized differently. A prompt from one source compared against a list from another. Casefold both sides, then compare - this node is the preprocessing step for a comparison, not the comparison itself.

    For that you'd normally pair it with the pack's string compare node, or feed the result into an if/else control-flow node. There's a real habit in the r/comfyui crowd of reaching for this pack precisely for conditional logic on text, and this is the node that makes the condition behave.

    Installing

    It ships in Basic data handling by StableLlama. In ComfyUI Manager, search "Basic data handling" → Install → restart ComfyUI. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Then restart. No models, no CUDA, no hidden dependencies - the pack's pyproject.toml declares zero runtime deps. It's pure Python stdlib, which makes it the rare install that can't start a dependency war with your other nodes.

    Where people get burned

    Don't confuse casefold with lower. For ASCII text they behave identically; for accented or special characters casefold is more aggressive. That's the point, but it means you shouldn't mix them - casefold one side and lower the other and you're back to mismatch town.

    And it's only useful if you fold both sides. Normalizing one string and comparing against the raw other is the most common mistake, because it looks like it should work. Also worth knowing: the pack's own string compare node, when you flip it to case-insensitive, just calls .lower() on both inputs. If you've got text with characters like ß where that falls short, run both sides through this node first and compare with == - that's the accurate path.

    CategoryBasic/STRING

    Inputs (1)

    NameTypeDefaultDescription
    stringSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING