Remove Empty Lines from Text, Code and Lists
Copying from web pages, PDFs, spreadsheets or chat apps often leaves gaps between lines. This tool will remove empty lines in one pass and keep every line that has real content, in its original order.
Example
Input: Output:
First line First line
Second line
Third line
Second line
(spaces only)
Third line
The input above has four empty lines: two truly empty ones, one that contains only spaces, and the empty line created by the final line break. All four are removed.
What counts as an empty line
By default, a line counts as empty when it has no characters or only whitespace such as spaces and tabs. These whitespace-only lines are easy to miss because they look blank but still take up a row.
If you turn that option off, only lines with zero characters are removed. A line containing a single space or tab is then kept. That is useful when the whitespace carries meaning, for example in fixed-width data.
Line endings
Windows (CRLF), classic Mac (CR) and Unix (LF) line breaks are all recognized. The cleaned text is joined with standard LF line breaks, which every modern editor handles.
The same clean-up in other tools
For a one-off paste, this page is quickest. When you need the same step in a script or editor, these commands match the default behaviour of removing both empty and whitespace-only lines:
sed '/^[[:space:]]*$/d' input.txt # Linux and macOS
grep -v '^[[:space:]]*$' input.txt # same result with grep
awk 'NF' input.txt # keeps lines with at least one field
Get-Content input.txt | Where-Object { $_.Trim() -ne '' } # PowerShell
In Notepad++ the menu item Edit → Line Operations → Remove Empty Lines (Containing Blank characters) does the same. In VS Code, open Replace, enable regular expressions and replace ^\s*\n with nothing. Note that the command-line versions keep the original line endings, while this tool rewrites them as LF, which matters if a Windows program expects CRLF.
Keep paragraphs instead?
This tool removes all blank lines, including the ones that separate paragraphs. If you only want to shrink large gaps down to a single blank line, use Remove Extra Spaces, which collapses repeated blank lines while tidying spaces. For a full clean-up of pasted text, including invisible characters, try the Text Cleaner.
Typical uses
- Compacting a list of URLs, email addresses or product codes before importing it.
- Removing blank rows from CSV data pasted from a spreadsheet.
- Cleaning code or configuration snippets copied from documentation with extra spacing.
- Preparing a list for Remove Duplicate Lines or sorting.
Privacy
The text is processed in your browser and is not uploaded anywhere.