String Functions
Empty Lines Remover
Strip blank or whitespace-only lines from any text — handy for cleaning up pasted content.
About Empty Lines Remover
Empty Lines Remover strips blank and whitespace-only lines out of pasted text. It doesn't collapse a run of blank lines down to one blank line — every blank line between two lines of content is removed entirely, so paragraphs that were separated by a gap end up on consecutive lines with a single line break and no gap. A line counts as "empty" if it has no characters, or only spaces and tabs; lines that contain real text are always kept, in their original order.
The transform is a single regex replace: input.replace(/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/g, '\n'). It matches any run of one or more line breaks, with optional whitespace in between, and collapses the whole run down to one \n. As a side effect it also normalizes Windows-style \r\n line endings to \n, even between lines with no blank line, because a lone \r\n pair itself matches the pattern. Everything runs client-side in your browser — the text is never sent to a server.
Reach for this when you've pasted content with blank-line noise: text copied from a PDF or Word doc, a log file with blank separators, a SQL dump, or a CSV export with stray blank rows. It also helps tidy config files or code snippets before sharing them, where blank lines add clutter but no information. One limitation worth knowing: if you want to keep single blank lines as paragraph breaks and only collapse doubled-up ones, this isn't that tool — it always reduces a run of blank lines to zero, not one.
Examples
first line
second line
third line
output:
first line
second line
third lineVerified against the tool's actual transform function — every run of blank lines collapses to a single line break, however many blank lines were in the run.
Our return policy covers items
purchased within the last 30 days.
Contact support with your order
number to start a return.
output:
Our return policy covers items
purchased within the last 30 days.
Contact support with your order
number to start a return.This is the part people don't expect: the tool doesn't preserve one blank line as a paragraph separator — it always collapses to zero, not one.
const cleaned = text.replace(/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/g, '\n');
// "a\n\n\nb" -> "a\nb"The exact regex the tool runs client-side (src/lib/tools/string-tools.ts) — reuse it in a Node script or build step for the identical behavior outside the browser.
Frequently asked questions
Does it collapse multiple blank lines into one blank line, or remove them completely?
It removes them completely. A run of one or more blank lines between two lines of text collapses to a single line break, not to one blank line — so there is no way to keep single-blank-line paragraph spacing with this tool.
Does a line with only spaces or a tab count as empty?
Yes. Any line containing nothing, or only spaces and tabs, is treated as empty and removed. Lines with actual text content are never touched.
Will this tool change my line endings?
Yes, as a side effect. A Windows-style \r\n line ending is itself matched as two line breaks by the tool's regex, so it gets normalized to a single \n — even on lines that had no blank line between them.
Is the text I paste in sent to a server?
No. The transform is a single regex replace() call that runs in your browser; nothing is uploaded, so it's safe to use on private text like config files or logs.
Does it also collapse extra spaces inside a line, or just remove blank lines?
Just blank or whitespace-only lines — it does not touch spacing within a line that has text. For collapsing repeated spaces inside a line, use the separate Extra Spaces Remover tool.