Remove Empty Lines
Delete all blank and empty lines from your text to create cleaner, more compact content without unnecessary gaps.
Related Tools
How to Use
- Paste Your Text — Paste text that contains unwanted blank lines — from code files, documents, or copied content.
- Choose Removal Mode — Select a mode: remove all blank lines (including lines with only spaces or tabs), consolidate runs of blank lines into a single blank line, or strict mode, which removes only truly zero-length lines.
- Copy Compact Text — Click Remove Empty Lines to replace your text with the compacted result, then copy or download it. Undo brings back your original text.
About Remove Empty Lines
Remove Empty Lines deletes blank lines from text and leaves every line that has content exactly as it was. Use it to compact a list copied from a web page or spreadsheet, tighten a config file or code snippet, or remove the gaps that email and chat apps put between messages. Three modes decide what counts as empty and how much spacing survives, and live counters show the total, blank and content lines, plus how many lines will be removed, before you click.
The three modes
- Remove all blank lines (default) deletes every line that is empty or contains only whitespace: spaces, tabs, non-breaking spaces or other Unicode spaces.
- Consolidate keeps one empty line between blocks of text. Each run of blank or whitespace-only lines becomes a single truly empty line, and blank lines at the very start and end are removed. Use it to keep paragraph spacing while removing the excess.
- Strict removes only zero-length lines and keeps lines that contain spaces or tabs. That matters in formats where a whitespace-only line means something, such as unified diffs, where an unchanged blank line is written as a single space.
In every mode the lines you keep are untouched, indentation and trailing spaces included. Windows (CRLF) and old Mac (CR) line endings are recognized, and the result uses LF. Your text is replaced with the result, and Undo restores it.
Worked example
Input, where ⏎ marks a line break, ␣ a space and → a tab: ⏎⏎Title⏎⏎⏎␣␣␣⏎Paragraph one.⏎→⏎Paragraph two.⏎⏎⏎. That is 11 line breaks, so the tool counts 12 lines, including the empty one after the last break.
| Mode | Output | Lines removed |
|---|---|---|
| Remove all blank lines | Title⏎Paragraph one.⏎Paragraph two. | 9 |
| Consolidate | Title⏎⏎Paragraph one.⏎⏎Paragraph two. | 7 |
| Strict | Title⏎␣␣␣⏎Paragraph one.⏎→⏎Paragraph two. | 7 |
Edge cases
- A final line break counts as an empty last line, so it is removed and the output does not end with a newline. POSIX defines a text line as ending in a newline, and some linters and command-line tools expect one, so add it back if your file needs it.
- Zero-width characters such as the zero-width space (U+200B) are not whitespace, so a line that contains only one is not empty and stays. The Invisible Character Detector shows where they are.
- Consolidate always leaves exactly one empty line between blocks. Some code styles expect more: Python's PEP 8, for example, puts two blank lines around top-level functions and classes, so use it on code with care.
- Line breaks inside paragraphs are not changed. If sentences are broken across lines, you need Remove Line Breaks instead.
When to use it
Compact a column pasted from a spreadsheet or web table before importing it elsewhere. Clean a word or keyword list in which every item is followed by a blank line. Tidy chat logs, email threads and exported transcripts. Prepare a list for Remove Duplicate Lines, which would otherwise keep one blank line as a unique entry. The guide How to Remove Empty Lines and Blank Lines From Text covers style-guide rules for blank lines in code and how to remove them programmatically.
Everything happens in your browser; the text is never uploaded.
Frequently Asked Questions
What counts as an "empty" line?
An empty line is any line that contains no visible characters. This includes completely blank lines as well as lines containing only spaces, tabs, or other whitespace characters. The tool treats both types as empty by default.
Can I keep single blank lines between paragraphs but remove extras?
Yes. The "Consolidate" mode collapses every run of blank lines (including whitespace-only ones) into a single empty line and removes blank lines at the very start and end of the text. This preserves paragraph separation while eliminating excessive vertical spacing.
Will this affect lines that contain only spaces or tabs?
By default, whitespace-only lines are treated as empty and removed. If you need to preserve lines that contain intentional whitespace (such as indentation markers in certain file formats), you can switch to strict mode, which only removes lines that are truly zero-length.
Is this useful for cleaning up source code?
Yes. Many code files accumulate excessive blank lines over time — between functions, after closing braces, or from careless editing. Consolidate mode reduces every run to a single blank line, which suits many style guides. Some expect more: Python's PEP 8 asks for two blank lines around top-level functions and classes, so check your project's conventions before cleaning code.
How does this differ from the Remove Line Breaks tool?
Remove Line Breaks joins non-blank lines together, merging wrapped text into continuous paragraphs. Remove Empty Lines preserves each content line on its own row but strips the blank lines between them. They solve different problems and can be used together for comprehensive cleanup.