How to remove empty lines
- Paste your text, list or code into the left box. Press Sample to see an example.
- Choose what to clean. Remove blank lines is selected by default; the cleaned text appears on the right as you type.
- The status under the result shows how many lines were removed.
- Press Copy or Download to save the result as a .txt file.
Which option should I use?
| Option | What it does | Good for |
|---|---|---|
| Remove blank lines | Deletes every empty or whitespace-only line | Lists, CSV data, email addresses, log files |
| Keep single blank lines | Turns runs of blank lines into one | Articles and code where paragraphs need a gap |
| Remove blanks + trim lines | Also strips spaces and tabs at the start and end of each line | Data pasted from spreadsheets or web pages |
| Remove duplicate lines | Keeps the first copy of each line, in order | Keyword lists, mailing lists, tags |
| Fix broken lines | Joins lines within each paragraph and rejoins hyphenated words | Text copied from PDFs, emails and e-books |
| Remove all line breaks | Joins everything into one line separated by spaces | Pasting into a single-line field, a spreadsheet cell or a prompt |
Remove empty lines in other apps
If you work in the same file often, these built-in methods are quicker than copying text back and forth:
- Notepad++: Edit > Line Operations > Remove Empty Lines (Containing Blank characters).
- VS Code: open Find and Replace (Ctrl + H), turn on regular expressions (Alt + R), find
^\s*\nand replace with nothing. - Microsoft Word: Find and Replace, search for
^p^p, replace with^p, and press Replace All until nothing is found. - Excel or Google Sheets: select the column, Find & Select > Go To Special > Blanks, then Delete > Delete Sheet Rows. In Sheets, use a filter and untick (Blanks).
- Linux and macOS:
sed '/^[[:space:]]*$/d' input.txt > output.txt - Windows PowerShell:
Get-Content input.txt | Where-Object { $_.Trim() } | Set-Content output.txt
Why blank lines cause problems
Blank lines are harmless in prose but break things in data. An empty row at the end of a CSV file can import as a record with no values, an extra line in a list of email addresses can count as a failed recipient, and blank lines inside a list of keywords or URLs inflate the count. Text copied from PDFs, web pages and chat apps often brings stray whitespace-only lines with it, which look empty but aren't, and which a simple "delete empty rows" in some apps misses. This tool treats both as blank.
Comments 0
No comments yet.