Text Split (NH)
Text Split (NH) does the parsing for you
- items_joined
- count
- first
- last
Half of ComfyUI text work is taking a messy string and turning it into pieces you can actually use. A prompt file gives you portrait, studio lighting, 85mm, a filename is batch_12_upper.webp, an API response is one long delimited blob. Text Split (NH) takes any of those and hands you the parts, plus a few useful summary numbers.
It's a simple node with a surprisingly good set of outputs. Feed it text and a delimiter, and you get:
- items_joined - the parts joined back together with newlines, which is handy for re-feeding into a multiline prompt box or a list node.
- count - how many pieces you got.
- first and last - the first and last item, so you can route on them without touching the middle.
That's the quiet win: first and last let you build logic without a full array. Need to branch on whether a tag list starts with highres? Compare first instead of splitting again.
How it works
It's Python's str.split() under the hood, which means the delimiter is treated literally - except it handles the two escape sequences you'll actually want: \n and \t become newline and tab, so you can split a prompt block on lines or tabs without fighting the UI. Items are stripped of whitespace and empty ones are dropped (so a trailing comma won't give you a phantom empty part).
The three inputs:
- text - the multiline string you want chopped up.
- delimiter - default is
", "(comma-space), which is the right call for tag lists. - max_splits - optional, default
-1meaning "split everywhere." Set it to a positive number and it limits how many splits happen, so a value with commas inside it survives - that's Python'smaxsplitargument.
When you'd reach for it
The classic case is tag-hopping: a wildcard or a text-file loader spits out a comma-separated tag list, and you want to split it, reorder the pieces, or pull out first/last for routing. It also shines as a cheap validator - count is a great way to gate a workflow ("only proceed if this file has at least 3 tags") without writing a conditional prompt parser.
One honest caveat: this node splits on a single delimiter and doesn't do patterns. If you need regex, the same pack has Regex Extract (NH) with match/findall/replace/split modes, and if your "delimiter" is actually newlines and you want every line as a separate downstream execution, Text Split Lines (NH) is the one - it outputs a real data list. Text Split is the middle ground: quick, readable, no regex knowledge required.
Install
It's part of NH-Nodes, so install the pack once and you get this plus ~70 siblings. ComfyUI Manager → search NH-Nodes → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
Then restart ComfyUI. No model files, no extra downloads - this is pure string handling, and it's one of those nodes that quietly disappears into a workflow and does its job for years.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| delimiter | STRING | , | — |
| max_splitsopt | INT | -1-1–100 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| items_joined | STRING | — |
| count | INT | — |
| first | STRING | — |
| last | STRING | — |