Nodes/VLM_nodes/Text Split / Batch
ComfyUI Node Runs on cloud

Text Split / Batch

Turn one blob of text into a real Comfy list for batched execution

By gokayfem·Created 3 years ago·Updated 9 days ago· 583
Text Split / Batch
    • items
    • items_json
    • item_count
    text
    modeLines
    delimiter,
    trim_itemstrue
    remove_emptytrue
    deduplicatefalse
    max_items0

    Batched execution is where ComfyUI shines, and VLMTextSplit is the node that feeds it. It splits a single block of text into a real Comfy STRING list - not a string that looks like a list, an actual list output that triggers the standard "batch the downstream nodes over these items" behavior. If you've ever gotten a workflow that fakes batching by joining text with newlines and then splitting it inside a single node, this is the honest version of that.

    The use case that matters most: you have a VLM or LLM return a list of things - ten detected objects, a batch of prompts, a CSV of tags - and you want to run a node once per item. Split the text into a list, wire it into a list-accepting input, and ComfyUI runs the downstream graph for each element.

    How it works

    Six split modes, chosen with a dropdown:

    • Lines - split on newlines (default).
    • Paragraphs - split on blank-line-separated blocks.
    • Literal delimiter - split on a fixed string (the delimiter field).
    • Regular expression - split on a regex.
    • CSV - proper CSV parsing (quoted fields, escapes) with a one-character delimiter.
    • JSON array - parse a JSON array and emit each element.

    After splitting, a common post-pass runs: trim_items (default on), remove_empty (default on), optional deduplicate, and an optional max_items cap (0 keeps everything). The delimiter field is shared by literal, regex, and CSV modes.

    Outputs

    • items - the real list (STRING, list-typed). This is the one that drives batching.
    • items_json - the same items as a JSON string, stable and deterministic, for inspection or API use.
    • item_count - how many items came out, for conditionals or logging.

    The items_json output is quietly important: it's the API/persistence boundary, so you can hand a downstream process the same data in a serializable form without re-splitting.

    Install

    Part of ComfyUI VLM Nodes (gokayfem/ComfyUI_VLM_nodes). ComfyUI Manager → search "VLM Nodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/gokayfem/ComfyUI_VLM_nodes
    python -m pip install -r ComfyUI/custom_nodes/ComfyUI_VLM_nodes/requirements.txt
    

    Run pip with ComfyUI's Python; the repo won't install its own torch. Pure Python, no models.

    Gotchas

    The one that bites: remove_empty is on by default and runs after trimming, so a split that produces blank lines (common from model output with trailing newlines) silently drops them. Usually good, occasionally surprising. Also, CSV mode demands a single-character delimiter - a two-character "delimiter" errors, by design. And remember max_items truncates blindly at the end; if you want the first N, that's fine, but there's no "last N" here, so plan your input accordingly.

    CategoryVLM Nodes/Text/Transform

    Inputs (7)

    NameTypeDefaultDescription
    textSTRING
    modeCOMBOLines6 options: Lines, Paragraphs, Literal delimiter, Regular expression, CSV, JSON array
    delimiterSTRING,Used by literal, regex, and CSV modes.
    trim_itemsBOOLEANtrue
    remove_emptyBOOLEANtrue
    deduplicateBOOLEANfalse
    max_itemsINT00–1000000 keeps every item.

    Outputs (3)

    NameTypeDescription
    itemsSTRING
    items_jsonSTRING
    item_countINT