OnlineNotes Logo

    Remove Empty Lines

    Paste text with gaps in it. Blank lines disappear as you type. Choose whether to close every gap or keep a single blank line between paragraphs.

    Options

    About this tool

    Blank lines pile up when text is copied out of a PDF, an email thread, a web page or a chat export. Each paragraph ends up two or three lines apart, and a list that should be 20 rows becomes 50. Pasting that into a spreadsheet or a form gives empty rows that then have to be deleted one by one.

    The usual trap is a line that looks empty but holds a space or a tab. Most quick fixes, such as a find and replace on two line breaks, miss those lines. The first option here treats them as empty too. The second option is for prose: it keeps paragraphs apart with a single blank line instead of joining everything into one block.

    How it works

    1. Paste your text into the input box.
    2. Every line is checked. A line with no characters, or only spaces and tabs, counts as empty.
    3. Empty lines are dropped. With "Keep one blank line" on, a run of empty lines becomes a single one.
    4. Copy the result. The numbers show lines in, lines out and how many were removed.

    Worked example

    Input

    Intro
    
    
    Point one
    
    
    
    Point two

    Output

    Intro
    
    Point one
    
    Point two

    With "Keep one blank line between paragraphs" on, each gap shrinks to one blank line. Turn it off and the result is three lines with no gaps.

    Edge cases and limits

    • Only whole lines are removed. Spaces inside a line stay. To clean those, use remove extra spaces.
    • Blank lines at the start and end are always removed, even with "Keep one" on.
    • Lines that hold only an invisible character, such as a zero width space, are not seen as empty.

    Frequently asked questions

    How do I remove blank lines in Notepad++?

    Use Edit, Line Operations, Remove Empty Lines (Containing Blank Characters). Windows Notepad has no such option, so pasting here is the quick way.

    How do I remove empty lines in Word?

    In Find and Replace, search for ^p^p and replace with ^p, and repeat until nothing is found. Lines with spaces need ^p ^p as well. Pasting here does both in one step.

    Can I remove empty lines with a regular expression?

    Yes. Replace ^\s*$\n with nothing in an editor that supports multi-line regex. This tool does the same without regex.

    Related tools