My Tool Studio
Text

Remove Empty Lines

Paste text here to remove empty lines instantly, including lines that look empty but hold spaces or tabs. The remaining lines keep their exact order. A common case is a column copied from Excel or Google Sheets, where every empty cell turns into a gap and a 30-item list spreads over 60 lines. You can remove every blank line, keep one blank line between blocks so paragraphs stay separate, or remove only the blank lines at the start and end. An optional trim cleans spaces off each kept line, and files can be opened and saved. The counter shows how many lines went in, how many came out and how many were removed. Writers use it on pasted transcripts, and developers use it on logs, SQL output and config files. It runs in your browser with nothing uploaded.

Always freeNo sign upRuns in your browser

How to use

01

Paste the text

Paste into the Text with empty lines box, or press Try sample to load a short column of order numbers with empty lines and lines that hold only spaces or a tab.

02

Choose what to keep

Pick Remove all empty lines, Keep one blank line between blocks, or Only at the start and end. Untick Count lines with only spaces or tabs as empty to keep those, and tick the trim option if needed.

03

Check the count and copy

The counter shows lines in, lines out and lines removed. When the Result pane looks right, press Copy, or Download .txt to save it as a file.

Why Remove Empty Lines

Example: a column pasted from Excel

The sample below is what a column of order numbers looks like after copying it from a sheet with empty cells. Some gaps are truly empty, one holds three spaces and one holds a tab. The last line is indented with spaces.

With Remove all empty lines, 12 lines go in and 6 come out: Order ID, 10452, 10453, 10457, the Notes line and the indented line. The indented line keeps its spaces unless the trim option is ticked. With Keep one blank line between blocks and trim on, each group of gaps becomes a single blank line and the indented line is trimmed, giving 10 lines.

Line in the inputRemove all empty linesKeep one blank line, trim on
Order IDOrder IDOrder ID
(empty)removedone blank line
104521045210452
(3 spaces), (empty)removedone blank line
104531045310453
(empty), (empty)removedone blank line
104571045710457
(tab)removedone blank line
Notes: second block starts hereNotes: second block starts hereNotes: second block starts here
indented line indented line indented line

Removing blank lines in other programs

If you prefer to stay inside the program you are using, these methods do the same job. Most of them remove every blank line, so to keep single gaps between paragraphs, paste the text here and choose Keep one blank line between blocks. Always keep a copy of the original before a bulk delete in a spreadsheet.

  • Excel: select the column, then Home, Find and Select, Go To Special, Blanks. Then use Delete, Delete Sheet Rows. Check first that no other column has data in those rows.
  • Notepad++: Edit, Line Operations, Remove Empty Lines. The Containing Blank characters version also removes lines with only spaces or tabs.
  • VS Code: open Find and Replace, turn on regular expressions, search for ^\s*\n and replace with nothing.
  • Command line: grep -v '^[[:space:]]*$' file.txt prints every line that is not blank.

Common questions

Does removing empty lines also catch lines that only contain spaces or tabs?
Yes, by default. Any line that is empty after its spaces and tabs are ignored is treated as empty and removed. Those whitespace-only lines are often why blank lines seem impossible to delete by hand. Untick Count lines with only spaces or tabs as empty if they matter, for example in Markdown or code.
How do I remove extra blank lines but keep paragraph breaks?
Choose Keep one blank line between blocks. Any run of two, three or more blank lines shrinks to a single blank line, so paragraphs stay separate. Blank lines at the very start and end are removed.
Will removing blank lines change the text on my other lines?
No, unless you tick the trim option. Without it, each kept line comes out exactly as you pasted it, indentation included. With it, spaces and tabs at the start and end of each kept line are removed.
How do I delete empty rows from a column copied out of Excel?
Copy the column, paste it here and copy the result back into the sheet. Each empty cell becomes an empty line and is removed. This works for a single column; for a table with several columns, use a filter on blanks in the spreadsheet instead.
Can I remove blank lines only at the start and end of my text?
Yes. Choose Only at the start and end. Blank lines before the first line of text and after the last one are removed, while every blank line inside the text stays where it is. It is a quick fix for pasted snippets and code that picked up empty lines at the edges.
Why do empty lines appear when I paste from a spreadsheet?
The spreadsheet copies the whole selected range, so every empty cell becomes an empty line. Merged cells add more, because a cell merged across three rows copies as one value and two empty lines.
How many lines were removed from my text?
Look at the counter above the output. It shows the number of lines in your input, the number in the result and the difference as lines removed. It updates every time you edit the text or change an option.
Does the remove empty lines tool handle Windows line endings?
Yes. Lines ending in CRLF, the Windows style, and LF, the Mac and Linux style, are both recognized. The output uses LF line breaks, which paste correctly into modern editors and spreadsheets.
Are blank lines ever worth keeping in code or Markdown?
Often, yes. Markdown uses a blank line to separate paragraphs, and many code style guides use blank lines between functions. For those files, use Keep one blank line between blocks rather than removing every blank line.
Is my text uploaded when I remove blank lines online?
No. The filtering runs in your browser, and nothing you paste is sent to a server. Large logs are processed on your own device.

More Text tools

View all