Nodes/ComfyUI_MqUtils/MQ Text Splitter
ComfyUI Node

MQ Text Splitter

The tag list splitter with a skip button (the one node in this pack with muscle)

By mikeshuangyan·Created about a year ago·Updated about a year ago· 1
MQ Text Splitter
    • STRING LIST
    • LENGTH
    text
    delimiter,
    start_index0
    skip_every0
    max_count10

    Of the four nodes in ComfyUI MqUtils, this is the one that justifies the install. MQ Text Splitter takes a chunk of text and breaks it into a list of items on a delimiter you choose - comma-separated tags, newline-separated captions, whatever - then lets you get selective about what you keep. Paste a civitai-style tag list in, get clean individual strings out. That's the 80% case.

    Why you'd reach for it: a huge amount of prompt work is really list work. You grab a caption file or a tag dump, and what you actually want is "give me these tags as separate items so I can feed them into a batch, compare subsets, or loop over them." Splitter is the tool for that, and three knobs on top turn it from a trivial split into a genuinely useful one.

    Mechanism first, because one detail decides whether it behaves. The delimiter is decoded with Python's unicode_escape, which means you can type \n into the delimiter field and get a real newline split. Each item is then stripped of whitespace and empty items are dropped, so trailing commas and stray blank lines vanish instead of becoming junk list entries. Then the slicing starts.

    The inputs that matter:

    • text - the multiline string to split
    • delimiter - default ","; accepts escapes like \n and \t
    • start_index - how many items from the front to skip
    • skip_every - take every Nth item after the start (1 = every other)
    • max_count - cap on how many items come back

    Outputs are STRING LIST (the items) and LENGTH (an INT telling you how many you got).

    The knobs are where it stops being a toy. Want to drop the boilerplate "masterpiece, best quality, ultra detailed" opener that every shared workflow opens with? start_index=2 skips the first two tags. Comparing half a tag list against the other half? skip_every=1 grabs every other item, the README's own example. Sharing a workflow that only fits three tags before your context window complains? max_count=3. And LENGTH is your sanity check and your loop counter - wire it to a comparison node and you can even branch on whether the list came back empty at all.

    Three gotchas, all real and all from reading the source. First, unicode_escape is a double-edged sword: the same feature that turns \n into a newline also interprets any backslash sequence you type. Splitting on a literal backslash is painful - if your data's separator is anything exotic, just pick a distinctive delimiter like ||| and stop thinking about it. Second, empty items are silently dropped, which is great for trailing commas and quietly destructive if you actually cared about an empty string in the middle of the list. Third, the output is a list, and most ComfyUI text inputs want a single string - you can't always drag STRING LIST straight into a prompt field. It feeds nodes that accept lists, or anything tolerant of Any, and LENGTH is there to keep you honest about what came out.

    Install the pack the usual way - ComfyUI Manager, search ComfyUI MqUtils, install, restart - or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mikeshuangyan/ComfyUI_MqUtils.git
    

    Restart, done, no dependencies to fight. If you work with tag lists at all, this node will quietly become the reason that pack stays installed.

    CategoryMQ Utils/Utils

    Inputs (5)

    NameTypeDefaultDescription
    textSTRING
    delimiterSTRING,
    start_indexINT00–1000
    skip_everyINT00–10
    max_countINT101–1000

    Outputs (2)

    NameTypeDescription
    STRING LISTSTRING
    LENGTHINT