Remove Empty Lines

Strip every blank line from any text or collapse runs of empty lines down to a single break. Useful for cleaning up exports, AI output, or copy-pasted content. Runs in your browser, no upload, no signup.

Input Load sample

How to use the remove empty lines tool

1. Paste the text

Drop your text into the Input box. The tool handles short snippets, full essays, log files, exported lists, and AI-generated content with extra spacing. Every kind of line break (LF, CRLF, CR) is normalised before counting empty lines, so files from Windows, macOS, and Linux all clean the same way.

2. Pick the rule

Default is Remove all empty lines. Turn on Collapse runs to keep paragraph spacing while flattening runs of three or more blank lines into a single break. Trim leading and trailing blank lines only removes the blanks at the very top and bottom of the text, leaving internal blanks intact. Trim invisible whitespace catches the lines that look empty but contain a non-breaking space or zero-width space.

3. Clean and copy

Click Clean. The output appears on the right with a count of empty lines removed. Use Copy or Download to save a .txt file.

When you need a blank line remover

Empty lines are easy to add by accident and surprisingly hard to remove cleanly with most editors. Six common cases where this tool helps.

AI-output cleanup
Output from ChatGPT, Claude, and other LLMs often has extra blank lines between paragraphs. Strip them in one pass before pasting into a CMS, an email, or a slide deck.
PDF or doc copy-paste
Pasting from a PDF or a Word doc often produces 2-3 blank lines per real line break. Remove all empty lines flattens the result so you can read or edit the prose.
CSV or TSV cleanup
Spreadsheet exports sometimes leave trailing blank rows. Strip the empty lines before re-importing so the parser does not throw on the blank cells.
Code or config file tidying
YAML, JSON, and config files do not care about blank lines. Collapse runs is the safest setting because it preserves the one-blank-line-between-blocks readability convention.
Email reply trim
Quoted-reply email threads often pick up extra blanks at the top of the message body. Trim leading and trailing blank lines clears the header gap without touching the body spacing.
Mailing list dedup prep
Before running a duplicate check on an email or address list, strip blank lines first so the dedup tool sees one address per line. Pair with Remove Duplicates as the next step.

What counts as empty

The word "empty" has a fuzzy edge in text processing. A line that looks empty in your editor can still carry one or more invisible characters: a non-breaking space at U+00A0, a zero-width space at U+200B, a zero-width joiner at U+200D, or a regular space-tab combo. The tool treats a line as empty when, after trimming whitespace and (optionally) trimming invisible whitespace, the line has zero visible characters. Lines that contain even a single visible character are always kept. The Trim invisible whitespace toggle controls whether NBSP and ZWSP count as whitespace or as real content. Most of the time you want this on, because LLM output and exports from word processors are full of these glyphs.

The line-break encoding does not matter. The tool normalises every newline style to a single LF before processing, then re-emits LF on output. If you specifically need CRLF for a Windows tool, paste the output into a destination that handles the encoding, or use a text editor like Notepad++ or VS Code to switch line endings.

Empty-line cleanup patterns

Four common input shapes and the settings that work best for each.

Input shapeSettingsResult
AI output with double-newline paragraphsCollapse runs onOne blank line between paragraphs, no triple-spaced gaps
PDF paste with random blank linesRemove all empty lines onContinuous prose with no blank gaps
Mailing list with trailing blanksTrim leading and trailing on, Remove all offList preserved, only top and bottom blanks dropped
Markdown export with NBSP-only linesRemove all on, Trim invisible onReal paragraph breaks survive, invisible-character blanks vanish

For other character-level stripping (whitespace, line breaks, punctuation, numbers, duplicates), browse all text removers.

Related tools

Frequently asked questions

How do I remove all empty lines from text?

Paste the text into the Input box on the left. Leave Remove all empty lines on and click Clean. Every blank line is removed and the rest of the lines stay in their original order.

What counts as an empty line?

Any line whose content is zero characters or only whitespace (spaces, tabs). Lines with even one visible character are kept. The tool also treats lines containing only invisible Unicode whitespace (no-break space U+00A0, zero-width space U+200B) as empty when the Trim invisible whitespace toggle is on.

What does Collapse runs do?

Collapse runs of empty lines into a single blank line preserves paragraph spacing but strips the rest. Useful when an export has 4-5 blank lines between sections and you want exactly one. The first blank line in each run stays, every subsequent blank line in the same run is removed.

Will the tool preserve indentation on non-empty lines?

Yes. Indentation, trailing spaces, and any non-empty content on a line are kept exactly as you pasted them. Only entire lines that contain no visible characters are removed.

How is this different from remove line breaks?

Remove line breaks flattens every line break into a space or other separator, producing one long line. Remove empty lines keeps the line breaks between non-empty lines, only deleting the blank ones. If you want one continuous paragraph, use Remove Line Breaks instead.

Does this work on Markdown or code?

Yes for Markdown. Be careful with code: in Python, indented blank lines inside a function body matter for some style linters, but the runtime ignores them, so stripping is usually safe. In YAML, blank lines can be significant inside multi-line strings, so use Collapse runs rather than Remove all if you are not sure.

Is my text uploaded anywhere?

No. Processing runs in client-side JavaScript. Nothing leaves the browser tab. We have no upload endpoint and we do not log content.

How do I remove only the empty lines at the top or bottom of a file?

Turn off Remove all empty lines and turn on Trim leading and trailing blank lines. Blank lines at the very start and very end of the text are removed, internal blank lines are preserved.

More wordcounter.ai tools

Other tools you might find useful.

Browse the full catalog →