Skip to content
TextBench Lab

Productivity

How to Remove Empty Lines From Text (5 Easy Ways)

Published 5 min readReviewed

On this page
  1. What does removing empty lines look like?
  2. How do you remove empty lines online in one step?
  3. How do you remove blank lines in Microsoft Word?
  4. How do you delete blank rows in Excel?
  5. How do you remove empty lines in Notepad++?
  6. How do you remove empty lines in VS Code?
  7. Which method should you use?
  8. Why do some empty lines not go away?
  9. Can you remove empty lines in Google Docs?

To remove empty lines, paste your text into our free whitespace cleaner, set Blank lines to Remove all, and copy the result. If your text lives in Word, Excel, Notepad++ or VS Code, each app has its own method, and the steps for each are below.

Every line that has text stays on its own line. Only the empty ones go.

What does removing empty lines look like?

Each blank line disappears, and the lines with text close up. Here is a short shopping list before:

Milk

Eggs

Bread


Butter

And after:

Milk
Eggs
Bread
Butter

The order of the lines does not change, and no line is joined to the next one. If you want to keep one blank line between paragraphs instead, choose Collapse to one.

How do you remove empty lines online in one step?

Use the whitespace cleaner. It runs in your browser, so your text is never uploaded.

  1. Paste your text into the blank line remover.
  2. Under Blank lines, choose Remove all.
  3. Check the Fixes list. By default the tool also trims spaces and collapses double spaces. Untick those fixes if every other line must stay exactly as it is.
  4. Copy the result, or download it as a .txt file.

The report shows how many blank lines were removed, so you can confirm the result at a glance.

How do you remove blank lines in Microsoft Word?

Use Find and Replace. In Word, a blank line is usually an empty paragraph, which means two paragraph marks in a row.

  1. Go to Home > Editing > Replace, or press Ctrl+H.
  2. Select the arrow at the bottom of the dialog box to show all options.
  3. Click in Find what, open the Special menu and choose the paragraph mark twice. Word fills in the code for you.
  4. Click in Replace with and choose the paragraph mark once.
  5. Select Replace All. Run it again until nothing more changes, because three or more blank lines in a row need more than one pass.

Microsoft documents the Replace dialog and the Special menu in Word's find and replace guide.

How do you delete blank rows in Excel?

Select the blank cells with Go To Special, then delete their rows.

  1. Select the column or range that holds your list.
  2. On the Home tab, select Find & Select > Go To, or press Ctrl+G.
  3. Select Special, choose Blanks, and select OK.
  4. Right-click one of the highlighted cells, choose Delete, then Entire row.

The selection steps come from Microsoft's Go To Special guide, and the delete step from deleting rows in Excel. Be careful with tables that have several columns: this deletes every row with a blank cell inside your selection, even if other cells in that row hold data. Press Ctrl+Z right away if you delete too much.

How do you remove empty lines in Notepad++?

Notepad++ has two built-in commands under Edit > Line Operations.

  1. Open the file.
  2. Go to Edit > Line Operations.
  3. Choose Remove Empty Lines for lines with no characters at all.
  4. Or choose Remove Empty Lines (Containing Blank characters) to also remove lines that hold only spaces or tabs.

According to the Notepad++ user manual, both commands work on the entire document, not on a selection. Copy the part you need into a new tab first if you want to clean only that part.

How do you remove empty lines in VS Code?

Use Replace with a regular expression.

  1. Open Replace with Ctrl+H (Windows, Linux) or Option+Cmd+F (Mac).
  2. Turn on regular expressions with the .* button, or press Alt+R (Option+Cmd+R on a Mac).
  3. In the find box, type ^\s*\n. This pattern matches a line that is empty or holds only spaces and tabs, together with its line break.
  4. Leave the replace box empty and select Replace All.

The shortcuts are in VS Code's default keyboard shortcuts. A regex that contains \n can match across lines, as the VS Code 1.29 release notes explain.

Which method should you use?

Pick the method that matches where your text already is.

Your situationBest method
Text copied from a PDF, email or web pageOnline whitespace cleaner
A Word documentFind and Replace with paragraph marks
A list in one Excel columnGo To Special, Blanks, delete rows
A large text or log fileNotepad++ Line Operations
Code or config filesVS Code regex Replace
A Google DocCopy it into the online tool, then paste back

Two related jobs need different tools. To join short lines into one paragraph, remove line breaks instead. To drop repeated lines as well as blank ones, remove duplicate lines and tick Ignore empty lines. For a full clean-up of a list, see cleaning an email list.

Why do some empty lines not go away?

They only look empty. A line can hold spaces, tabs or invisible characters that you cannot see on screen.

  • Word: a paragraph that holds a space is not two paragraph marks in a row, so the Replace step skips it.
  • Excel: a cell with a space in it is not blank, so Blanks does not select it.
  • Notepad++: the plain Remove Empty Lines command skips these lines; use the (Containing Blank characters) version.
  • Online tool: lines with only spaces or tabs count as blank. With the default fixes on, non-breaking spaces and zero-width characters are cleaned first, so those lines go too.

To see what a line really holds, paste it into the whitespace cleaner and tick Show invisible characters.

Can you remove empty lines in Google Docs?

Not with a documented built-in method. Google Docs supports regular expressions in Find and replace, but Google's find and replace help says replacements with special characters such as \n only work in Google Sheets. The reliable way is to copy the text into the online tool, remove the blank lines, and paste the clean text back.

Related tools