段落字数条件过滤行🐠meeeyo.com
Keep only the lines that are the right length — a dumb filter that's quietly great
- STRING
If you've ever had a list of prompts where half of them are one-word slop and the other half are essays, you've already wanted this node. FilterLinesByWordCount (段落字数条件过滤行 - "filter lines by character-count condition") takes a multi-line block, drops every line that isn't within a length range you set, and hands back the survivors. One input, one STRING output, zero drama.
How it works
Two inputs: input_text (multiline) and word_count_range, a string like 2-10. The node splits the text into lines and keeps any line whose length is between the min and max - inclusive on both ends. Output is the surviving lines joined back with newlines.
The naming is a small lie worth knowing about. "Word count" is really character count - it's Python's len(), so for English text "the cat" is 7, not 2, and for Chinese text it counts characters too. That's not a bug; it's how the pack author's audience (Chinese-language workflows) naturally thinks about 字数, "character count." But if you came here expecting a proper word tokenizer, adjust your expectations. For Chinese text this is actually perfect, since words don't have spaces between them anyway. For English, you're filtering by raw length, which is still fine for a rough "keep the short tags, drop the long paragraphs" pass.
Only a range works - no "longer than X" single-bound mode. No 2- or -10; it must be min-max.
Why you'd reach for it
Batch cleanup. It's the go-to when a generator or an upstream node dumps 50 prompt lines and you want to keep only the ones that fit your use - say, all lines under 10 characters for negative-prompt keywords, or only substantial scene descriptions for a video prompt. It composes cleanly with ExtractLinesByIndex (split a block into chunks) and the pack's other line tools.
Install
Standard StringOps install:
cd ComfyUI/custom_nodes
git clone https://github.com/MeeeyoAI/ComfyUI_StringOps.git
Restart ComfyUI. Or via ComfyUI Manager → search "ComfyUI_StringOps". No models, no heavy dependencies - pure Python. UI is Chinese (filter lines by character count) with the 🐠meeeyo.com fish branding and a contact ad in the node description, same as every node in this pack.
Common issues
The character-vs-word thing is the one that'll actually bite you. If you set 2-10 expecting "2 to 10 words," every English line over 10 characters vanishes and you'll think the node is broken. Also note it filters per line - a blank line is length 0, so it never survives a range starting above 0, which is usually what you want anyway. And there's no "drop lines that match" mode here - to keep everything except a length range, you'd invert it manually or use the substring-based FilterLinesBySubstrings sibling.
Simple, honest, and for the batch-prompt workflows this pack targets, it does a genuinely useful job. Just remember it counts characters, and it'll treat you well.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| input_text | STRING | — | |
| word_count_range | STRING | 2-10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |