ComfyUI Node

Text Case

Upper, snake, camel, and friends

By wwsmiao·Created 4 months ago·Updated 4 months ago· 0
Text Case
    • text
    text
    caselower

    TextCase is the tidy-up node: one string in, one string out, with the casing normalized to whatever you asked for. It's the "make this consistent before it goes somewhere that cares" step of the wwdm-aicd pack - and there are more places that care than you'd think, from filename-safe prompt variants to tag lists that need matching casing.

    The case dropdown has eleven options, and they split into two families. The simple ones are Python built-ins: upper, lower, title, capitalize, swapcase. The interesting ones are the programming-naming conversions - camel (camelCase), pascal (PascalCase), snake (snake_case), kebab (kebab-case), constant (CONSTANT_CASE) - which are what you reach for when text is going into a filename, an API key field, or any place where "hello world" needs to become hello_world. There's also sentence, which uppercases the first character and leaves the rest alone.

    Mechanically, the naming conversions are where the node shows its hand. It tokenizes with a regex ([A-Z]?[a-z]+|[A-Z]+(?=[A-Z]|$|\d)|\d+), lowercases each token, and rejoins with the appropriate separator or capitalization. That handles the common cases - "hello world" → camel helloWorld, constant HELLO_WORLD - and it also does something nice: it can normalize text that's already half-cased, like "camelCase" → snake camel_case. But it's not magic. It's built around the "words separated by non-alphanumeric characters or case boundaries" assumption, so genuinely weird input like "a1B2C3" will tokenize in ways that may surprise you. If the conversion you need is exotic, this is a place to test before trusting.

    The subtle difference most people miss: capitalize and sentence are not the same. Python's capitalize() uppercases the first character and lowercases everything else; sentence just uppercases the first character and leaves the rest untouched. So "hELLO wORLD" → capitalize "Hello world" but sentence "HELLO wORLD". Worth knowing which one you actually want.

    One input, one output, nothing else: text in, text out. Install is the standard pack story:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wwsmiao/comfyui-wwdm-aicd.git
    

    Restart ComfyUI, look under wwdm-aicd. Pure stdlib, no dependencies, no requirements.txt in the repo despite what the README's install section implies - clone and restart is all it takes. README and code comments are in Chinese; widget labels are English.

    Where it fits: the README's text-cleaning pipeline is TextTrim → TextReplace → TextCase → TextLength, and that's exactly right - trim the junk, swap the symbols, normalize the case, then verify length. It's also the node you'd use to match tag casing between two sources before TextJudge compares them, since "dog" vs "Dog" will fail an equals check. It's a one-trick node, but the trick is one you keep needing.

    Categorywwdm-aicd

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    caseCOMBOlower11 options: upper, lower, title, capitalize, swapcase, camel, +5

    Outputs (1)

    NameTypeDescription
    textSTRING