Nodes/ComfyUI-JakeUpgrade/Get Nth String JK๐Ÿ‰
ComfyUI Node

Get Nth String JK๐Ÿ‰

Get Nth String JK

By jakechaiยทCreated 2 years agoยทUpdated 3 months agoยท 147
Get Nth String JK๐Ÿ‰
    • string
    • int
    • float
    • boolean
    โ—„string_list1.0, 2.0, 3.0โ–บ
    โ—„index0โ–บ

    Somewhere in a real workflow, a list always ends up as a comma-separated string - a JSON export, a prompt file, an array pasted into a text field. Get Nth String JK is the pocket index into those strings: give it "1.0, 2.0, 3.0" and an index, and it hands back the item as STRING, INT, FLOAT, and BOOLEAN on four outputs. One node, every type you might need downstream, no conversion ladder.

    The mechanism is simple and predictable: the input is split on commas or newlines, the whitespace is stripped, and index selects the item. Two details make it friendlier than it looks:

    • Negative indices count from the end. index = -1 is the last item, exactly like Python. That's the flag to reach for when you want "the last seed from this list" without knowing the length.
    • Type conversion is forgiving. The string output is always the raw item; INT and FLOAT try to parse and fall back to 0 / 0.0 if the text isn't numeric (so "cat" becomes int 0 rather than an error); BOOLEAN recognizes the usual truthy/falsy strings - true, 1, yes, on vs false, 0, no, off - and otherwise uses Python truthiness. If your list is "yes, no, maybe", index 0 gives boolean true, index 1 gives false.

    That permissive conversion is both the feature and the trap: because INT/FLOAT never error, a typo silently yields 0. If a downstream KSampler suddenly gets zero steps, this node is a strong suspect - check that the list item actually parses.

    Install. It's part of ComfyUI-JakeUpgrade:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jakechai/ComfyUI-JakeUpgrade
    cd ComfyUI-JakeUpgrade
    pip install -r requirements.txt
    

    Or ComfyUI Manager โ†’ "JakeUpgrade". Windows portable: install.bat or ../../../python_embeded/python.exe -s -m pip install -r requirements.txt. Restart. Light dependencies - no model downloads.

    Gotchas: an out-of-range index raises a clear "Index X out of range" error rather than returning something empty - good for debugging, annoying in loops unless you bound your index. And because this node pairs naturally with the pack's Save/Load String List To/From JSON nodes (which turn file-backed lists into exactly this comma-joined format), you'll often see all three together in Jake's workflows. Pack rules: LOAD_DEPRECATED_NODES = True if JK nodes come up missing, disable ComfyUI MultiGPU per the README for CUDA-error avoidance.

    Category๐Ÿ‰ JK/๐Ÿ“ฆ Misc

    Inputs (2)

    NameTypeDefaultDescription
    string_listSTRING1.0, 2.0, 3.0Comma-separated list of values
    indexINT0-1โ€“100Index of item to retrieve (negative values count from end)

    Outputs (4)

    NameTypeDescription
    stringSTRINGโ€”
    intINTโ€”
    floatFLOATโ€”
    booleanBOOLEANโ€”