ComfyUI Node

SelectLists

Toggle whole list items on and off, then get a clean list or string

By sp8999·Created 6 months ago·Updated 6 months ago· 8
SelectLists
  • ANY
  • list
  • text
toggle_states_json{}

SelectLists is the sibling of SelectTexts, with one key difference in what you toggle. Where SelectTexts parses a comma-separated string into individual tags, SelectLists treats each item in the input list as a single unit and gives you an ON/OFF toggle per unit. Feed it a list of five prompt fragments, toggle three of them, and you get a list (and a joined string) of just the three you kept. The README describes it as "toggling at the list item level," and that's exactly right - it's the coarser-grained cousin.

How it works

The ANY input is list-oriented (the node sets INPUT_IS_LIST, so it expects to receive a batch rather than a single value), and every item gets a toggle button rendered by the bundled JS. Internally it follows the same playbook as SelectTexts: a hidden toggle_states_json widget holds the switch state, synced with a server-side store via the pack's /select_texts/set_states endpoints, and IS_CHANGED hashes both input and state so it re-runs when either changes. Items whose toggle is ON are collected, and here's the useful bit - they're flattened through the pack's convert_array helper, which splits nested lists and comma-separated strings inside each item down into clean individual strings.

Two outputs, which is what makes it a genuine utility rather than a curiosity:

  • list - the ON items, flattened, as a list (batch).
  • text - the same items joined into a single comma-separated string.

Because of that flattening, an all-ON SelectLists is a perfectly good list flattener: nested list in, flat list and clean string out. If no items are ON, it returns an empty list and empty string instead of erroring - a small detail, but one the author clearly bothered to handle.

SelectLists vs. SelectTexts

  • SelectTexts parses inside the string: tag1, tag2, (group:1.2) becomes toggles for each tag, and it preserves nested weight structure on rebuild.
  • SelectLists toggles at the item level: whatever came in as one list entry is one toggle, no parsing inside. Faster to wire, less clever, and it gives you both a list and a text output.

Use SelectLists when your units are already discrete - whole prompt fragments, per-LoRA tag groups, a list of outputs from elsewhere - and SelectTexts when you need per-tag control inside a comma blob.

Gotchas

  • Wire-driven input. ANY is forced to an input; there's no editable text box. The input also ignores images - it's meant for Text and List types.
  • Toggle state is per-node. Duplicate the node and each copy keeps its own switches, keyed by node ID.
  • Flattening is aggressive. If you rely on the input's original nesting surviving, it won't - convert_array splits every comma-separated string it finds. If you need structure preserved, that's SelectTexts' job, not this node's.

Installation

Zero dependencies, no model downloads. Install via ComfyUI Manager (search ComfyUI-Text-Utils-sp) or:

cd ComfyUI/custom_nodes
git clone https://github.com/sp8999/ComfyUI-Text-Utils-sp.git

Restart ComfyUI, find it under text_utils_sp. README caveat: tuned for the Nodes 2.0 frontend - on the v1 renderer it still runs, but the toggle widgets can render at the wrong size.

Categorytext_utils_sp

Inputs (2)

NameTypeDefaultDescription
ANY*
toggle_states_jsonoptSTRING{}

Outputs (2)

NameTypeDescription
list*
textSTRING