Remove Blank Lines
Strip empty lines out of a multiline string
- STRING
A small, boring, genuinely useful node: paste in a block of text with stray empty lines scattered through it, get back the same text with those empty lines gone. If you've ever copy-pasted a prompt list from a spreadsheet, a chat export, or someone else's workflow and ended up with mystery gaps between entries, this is the fix.
How it works
It splits the input on line breaks, keeps only the lines that have something on them once whitespace is stripped for the check, and joins what's left back together with newlines. One detail worth knowing: it only checks the stripped version of each line to decide what counts as blank - it doesn't actually trim the lines it keeps. A line like " actual text " survives with its leading and trailing spaces intact; only lines that are entirely empty or entirely whitespace get dropped.
The inputs and outputs that matter
text- the multiline string to clean up. That's the only input.
Output: a single STRING, the same content with every blank/whitespace-only line removed.
What it's actually for
The obvious pairing is anything downstream that treats your text as a list - a line-by-line prompt iterator (the pack's own TextFileLineIterator, or any wildcard/line-picker node) that indexes into your text by line number. A stray blank line in the middle shifts every index after it by one, which turns into confusing off-by-one bugs that have nothing to do with your actual logic. Running text through this node first means "line 5" actually means line 5 of your real content, not line 5 counting blank filler.
It's also just a reasonable first step any time you're feeding a hand-pasted block of text into something that's going to count or index its lines - pair it with CountTextLines (same pack) if you also need to know exactly how many real lines you ended up with.
Installing it
Search cspnodes in ComfyUI Manager, or clone it directly:
cd ComfyUI/custom_nodes
git clone https://github.com/cerspense/ComfyUI_cspnodes
Restart after. The pack ships as one Python file that unconditionally imports diffusers and pymediainfo at the top - dependencies the video-generation and metadata nodes elsewhere in the pack actually need. This node touches neither, but if either import fails, the whole cspnodes category disappears from your node list, this one included. Check the startup log for an import error before assuming something's wrong specifically here.
Where people get tripped up
There's genuinely not much to trip over - this node has one input and does one thing. The most common surprise is expecting it to also trim whitespace from the lines it keeps, since that's what a lot of "clean up my text" tools do by default. It doesn't: only fully-blank lines get removed, real content lines pass through byte-for-byte, spacing and all. If you need whitespace trimmed too, that's a separate step.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |