LTLine Toolkit

Tools / Remove empty lines

Remove Empty Lines

Strip blank lines and lines that contain only spaces or tabs, without touching real content.

Everything runs in your browser. Your text is never uploaded or stored.

How it works

Empty lines sneak in when you paste from a PDF, copy a column out of a spreadsheet that had gaps, or join several files together. They break SQL batches, confuse CSV importers that treat each line as a record, and inflate line counts in reports.

This tool removes any line whose content is empty or contains only whitespace. A line with a single non-breaking space typed from a web page is treated as whitespace and removed, while a line with any visible character, including punctuation, an emoji or a zero, is kept. That distinction matters: a line containing only - is real content and is preserved.

Edge cases

Do it in code instead

The same result with a shell one-liner or a few lines of Python, if you would rather automate it:

Bash (sed)

sed '/^[[:space:]]*$/d' list.txt

Bash (grep)

grep -v '^[[:space:]]*$' list.txt

Python

print('\n'.join(l for l in open('list.txt').read().splitlines() if l.strip()))

JavaScript

text.split('\n').filter(l => l.trim() !== '').join('\n');

Questions

Does it remove lines with only spaces?
Yes. A line made of spaces, tabs or non-breaking spaces counts as empty and is removed. Only lines with at least one visible character survive.
Will it join my paragraphs together?
No, it only deletes the blank lines. The remaining lines keep their own line breaks, so separate paragraphs become adjacent lines rather than merging into one.
Why did a blank line survive?
Most likely the line contains an invisible character such as a zero-width space. Those are not classified as whitespace, so the line is treated as content. Remove them with a find-and-replace on the character first.

Last verified: 2026-12-04