JDCN_StringManipulator
Slice, shuffle, and rejoin prompts and tags
- text
- index_from
- index_to
- batch_size
Some nodes do one thing; this one is a pocket knife for text lists. JDCN_StringManipulator takes a block of text, splits it on whatever separator you like, picks a handful of items out of it - from the top, from the bottom, or at random - and rejoins them with a different separator. The classic use: you've got a big comma-separated tag list or a pile of prompt fragments, and you want to grab a specific slice of it each run to feed a sampler. That's this node's entire reason to exist.
How it works
The flow is split β select β join, with a knob at every step:
- Split your text using
separator(Comma, Semicolon, Pipe, Hyphen, Colon, Space, Tab, Newline, and more, plus a Custom option where you type your own incustom_separator). Everything is trimmed of whitespace. - Select
batch_sizeitems.orderdecides how:toptobottomtakes items starting atindex;bottomtotopwalks the list reversed;randompulls a random sample. Theindex_changeoption (fixed/increment/decrement/random) is declared on the node, but in the shipped code it doesn't actually do anything yet - selection is driven byindexandorder. Don't build logic around it until an update wires it up. - Join the selected items using
joiner(same menu, or acustom_joiner).space_before_joinadds a space after the joiner - useful when you're gluing with commas for prompt syntax.
Outputs
- text - the final re-joined string.
- index_from and index_to - the range of source indices you just pulled (for
randomorder these are informational, not the actual sampled indices). - batch_size - echoed back so downstream nodes can see the batch size without a separate constant.
The node returns ("Index error", 0, 0, 0) if the selected range is empty - e.g. index beyond the end of the list. It won't crash, but you'll see "Index error" in the text output and should widen the range.
Where it fits
- Cycling through a saved list of prompt fragments, one batch per queue, for variation runs.
- Pulling K random tags from a big tag pool for dataset-style exploration or wildcard-style prompt construction.
- Chunking a caption list before saving it with
JDCN_TXTFileSaver.
If your workflow already has a text-utility pack like rgthree or a Python expression node, you may not need this. But it's self-contained and does the one thing - "give me a slice of this text list" - without dependencies.
Install
Part of ComfyUI-JDCN. ComfyUI Manager β Install Custom Nodes β search "JDCN", or:
cd ComfyUI/custom_nodes
git clone https://github.com/daxcay/ComfyUI-JDCN.git
pip install -r requirements.txt
Pack dependency is just piexif. No models.
Gotchas
- Order matters -
bottomtotopreverses before slicing, soindexcounts from the end. Getting "the last 3" requiresbottomtotopwithindex=0, not a negative index (there are none here). - Custom separators default to
NA- if you pick Custom and leave it at the default, the split behaves oddly. Type an actual separator. - Index error strings - an out-of-range selection doesn't fail the queue; it quietly emits "Index error" text. In a long automation run, that can pollute a prompt with literal words. Watch for it.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | concept | β |
| index | INT | 0 | β |
| index_change | COMBO | 4 options: fixed, increment, decrement, random | |
| order | COMBO | 3 options: toptobottom, bottomtotop, random | |
| separator | COMBO | 15 options: Comma, Semicolon, Pipe, Hyphen, Colon, Period, +9 | |
| custom_separator | STRING | NA | β |
| batch_size | INT | 1 | β |
| joiner | COMBO | 15 options: Comma, Semicolon, Pipe, Hyphen, Colon, Period, +9 | |
| custom_joiner | STRING | NA | β |
| space_before_join | BOOLEAN | false | β |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| text | STRING | β |
| index_from | INT | β |
| index_to | INT | β |
| batch_size | INT | β |