ComfyUI Node

String Case

One click to stop fighting your prompt's capitalisation

By TakkunRed·Created 5 months ago·Updated 15 days ago· 1
String Case
    • result
    ◄text►
    ◄modeupper►

    String Case converts a string's case: all caps, all lower, title case, sentence case, or swapped. It's the most boring node in the TakkunRed ComfyUI-String-Function pack, and you'll be grateful it exists the first time an LLM hands you a prompt written in SHOUTING or a caption file comes out as mASTERPIECE. One node, five modes, no configuration beyond picking one.

    Why bother in an image pipeline at all? Because text in a ComfyUI graph is rarely typed by hand these days. It comes from LLM nodes, from caption files, from prompt lists you've pasted together - and each source has opinions about capitalisation. When you're chaining an extractor into an encoder, normalising case upstream is a cheap way to stop garbage text from looking like garbage tokens.

    How it works

    It's a thin wrapper over Python's built-in string methods, which is why it's dependable and has no dependencies. The five modes, from the source:

    • upper - hello world → HELLO WORLD
    • lower - HELLO WORLD → hello world
    • title - hello world → Hello World (every word capitalised)
    • capitalize - hello world → Hello world (first letter of the whole string only)
    • swapcase - Hello World → hELLO wORLD (inverts existing case)

    The one caveat carried straight from Python: title capitalises after any non-letter, so don't becomes Don'T. If that bugs you, capitalize or lower are the saner options for real prose.

    Inputs and outputs

    Two required inputs: text (the string to convert) and mode (the dropdown). One output: result (STRING).

    Nothing else to set. It's a pure pass-through transform - wire text in, get text out - which makes it ideal for dropping inline into a string chain without disturbing the graph around it.

    Installing it

    Same pack, same zero-dependency install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TakkunRed/ComfyUI-String-Function
    

    Or search "ComfyUI-String-Function" in ComfyUI Manager, restart, and look under String Function.

    Where people get burned

    • title case is naive about apostrophes (the Don'T problem). For anything that goes into an actual encoder, lower or capitalize are usually the safer normalisation.
    • It normalises the whole string - there's no "first word only" or per-tag mode. If you need per-word control, pair it with a String Split and a bit of graph plumbing.
    • If you're normalising tags for a Danbooru-style model, check what the model was actually trained on before you lower everything. Some tag lineages are case-sensitive in how they were embedded; case-folding can silently change a tag's meaning.

    For a genuinely thin utility, that's the whole story: pick a mode, get a consistent case, move on.

    CategoryString Function

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING—
    modeCOMBOupper5 options: upper, lower, title, capitalize, swapcase

    Outputs (1)

    NameTypeDescription
    resultSTRING—