Skip to main content

Remove empty lines

Tidy up a text in one click by deleting every empty line and every line that holds only spaces or tabs, while leaving all other lines exactly as they are.

  • Clipboard
Automate

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Was this tool useful?

How does this tool work?

Remove empty lines and lines made only of spaces and tabs, without changing the other lines. It is handy after copying from a PDF, a spreadsheet or an email that left stray blank lines behind.

The tool goes through the text line by line and removes the lines that contain no meaningful character. The lines it keeps retain their content and order, including spaces at their start or end. Note that blank lines used to separate paragraphs disappear too. The tool removes neither duplicates nor spaces inside lines. A line can look empty yet contain invisible spaces or tabs. The tool removes those lines just like completely empty ones. Do not confuse this operation with a full text clean-up, though: spaces on non-empty lines stay in place and duplicates are not removed. In a list of identifiers, removing empty lines makes counting and importing easier. In an article or a message, the same operation can erase the gaps between paragraphs and make the text harder to read. So decide whether the blank lines are mere copy-and-paste artefacts or a deliberate part of the layout. For code, Markdown or files where empty lines have a function, work on a copy and check the structure afterwards. Windows line endings are converted to plain line feeds, which can alter a file meant for a tool that is sensitive to its exact format. If you would rather reduce repeated spaces inside sentences, use a text cleaner with suitable options. To check the result, count the content lines before and after. The number of non-empty lines should stay the same, even though the text gets shorter. Also look at a few places where two paragraphs used to be separated by a blank line.

How to use this tool

  1. Paste the text

    Type or paste the content to clean.

  2. Remove empty lines

    Run the tool to delete the lines without content.

  3. Read the result

    Check paragraph breaks before copying.

Use cases

Cleaning a list

Remove the blank lines from an export before counting or comparing its items.

Preparing a paste

Get a continuous run of lines to paste into a form or a spreadsheet.

Checking paragraphs

Make sure that removing the visual gaps does not hurt the readability of the text.

Examples

Empty lines removed

The empty line and the line made of two spaces both disappear.

Input

A

  
B

Result

A
B

Indentation kept

Only empty or blank lines disappear: the indentation of the remaining lines is untouched.

Input

Shopping

  - bread


  - milk

Result

Shopping
  - bread
  - milk

Tips and best practices

  • Spaces on non-empty lines are kept.
  • Blank lines between paragraphs are removed: check the final layout.
  • Windows line endings (CRLF) become plain line feeds (LF) in the result.

Frequently asked questions

Are lines containing only spaces removed?

Yes, as are lines containing only tabs or a mix of both.

Do spaces on other lines disappear?

No. A line that contains text is kept as it is, with its spaces and indentation.

Are paragraph breaks kept?

No, blank lines used as separators are removed. To keep them, run the tool only on the part that needs fixing.

Does the order of the lines change?

No. The remaining lines keep exactly their original order.

Are duplicates removed?

No, use the duplicate remover for that.

Related tools

Tools similar or complementary to this one.

Similar tools

Remove extra spaces, repeated tabs and empty lines from copied text.

Text & writingFeaturedUse this tool

Convert text to lowercase, UPPERCASE, Title Case or other common case styles.

Text & writingFeaturedUse this tool

Replace a text fragment in a pasted or imported document.

Text & writingNewUse this tool