Split And Join
Clean up a prompt's spacing and stray commas in one pass
- STRING
Prompts built up through several search-and-replace passes, parameter removals, or conditional string logic tend to end up messy - double commas where a tag got removed, extra spaces where a word got swapped for a shorter one, that kind of thing. JNodes_SplitAndJoin is the pack's own fix, and its own README description is the clearest summary there is: it "splits input text and rejoins each item with a delimiter. Great for removing extraneous spaces and commas from a display prompt."
The mechanism is simple on purpose: split the text apart on one delimiter, then rejoin the pieces with another (often the same) delimiter, but cleanly this time - which has the side effect of collapsing any repeated or stray delimiters into single, consistent ones, and trimming odd whitespace that piled up around them.
How it works
text is the input string. split_at is what to split on - typically a comma, since prompts are usually comma-separated tag lists. join_with is what to rejoin the pieces with - often , (comma-space) even if you split on a bare comma, which is exactly how you fix inconsistent spacing after tags. Because splitting drops empty pieces from double delimiters and the rejoin puts a single, well-formed separator back between every remaining item, the round trip normalizes messy punctuation without you having to write custom cleanup logic.
The inputs and outputs
text(STRING, multiline) - the text to clean up.split_at(STRING) - the delimiter to split on.join_with(STRING) - the delimiter to rejoin with.STRINGoutput - the cleaned, rejoined text.
How to install it
Via ComfyUI Manager: Install Custom Nodes, search "JNodes", install, restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/JaredTherriault/ComfyUI-JNodes
pip install -r ComfyUI-JNodes/requirements.txt
then restart ComfyUI. No model downloads - plain text processing.
Common issues & troubleshooting
Where to actually put this in your graph. It's a cleanup step, so it belongs at the end of a prompt-assembly chain - after JNodes_SearchAndReplace, after JNodes_RemoveParseableDataForInference, after whatever string surgery you've done - right before the text goes to your display, your saved metadata, or your CLIP encoder (which doesn't strictly need clean spacing, but a human reading the prompt later will thank you).
Splitting on a delimiter that also occurs inside your actual content. If you split on a comma but one of your tags legitimately contains a comma inside parentheses (an attention-weighted phrase, say), that phrase gets split apart too. Pick a split_at value specific enough to only match your intended separator, or pre-protect any content you don't want touched.
Expecting semantic cleanup, not just punctuation. This node normalizes delimiters and whitespace - it doesn't deduplicate repeated words or tags, and it doesn't understand meaning. If your prompt has "red dress, red dress" typed twice, this node will happily leave both.
join_with set to something different from split_at and getting unexpected output. That's intentional and often exactly the point (split on a bare comma, rejoin with comma-space), but if you weren't expecting the delimiter to change shape, double-check both fields are set the way you meant.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| split_at | STRING | — | |
| join_with | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |