How to remove empty lines
- 1 Type or paste your text into the left box, open a .txt file, or press Try an example.
- 2 Choose Remove all empty lines or Keep one empty line between paragraphs, and whether lines with only spaces count as empty.
- 3 The result appears on the right straight away and updates as you type.
- 4 Press Copy result or Download .txt, or Use as input to keep editing.
Blank lines, line breaks and spaces
Removing empty lines keeps each line separate. To join lines into a paragraph instead, use Remove Line Breaks, and to fix spaces inside lines, Remove Extra Spaces.
- Keep one empty line between paragraphs for readable text.
- Treat space-only lines as empty for copied text.
- Remove empty lines before sorting a list.
Features
Two modes
Remove all blank lines, or keep one between paragraphs.
Catches hidden spaces
Lines with only spaces or tabs count as empty.
Trims line ends
Optionally removes spaces at the end of each line.
When to use it
Lists and data
Turn a list with gaps into one item per line before sorting. Then use Sort Lines Alphabetically.
Copied web text
Fix text pasted from websites and emails with large gaps.
Code and config files
Remove blank lines from code or data files before sharing. To remove repeated lines too, use Remove Duplicate Lines.
Documents
Tighten up text before pasting it into a document or form. For spacing inside lines, use Remove Extra Spaces.
Related Text tasks
Frequently asked questions
What counts as an empty line?
A line with nothing on it. With the option on, lines containing only spaces or tabs are treated as empty too, since they look blank.
How do I keep paragraphs separate?
Choose Keep one empty line between paragraphs. Runs of several blank lines become one, so paragraphs stay apart but the extra gaps disappear.
Is this different from removing line breaks?
Yes. This tool removes blank lines but keeps each line of text on its own line. To join lines into a paragraph, use Remove Line Breaks.
Will my text lines change?
No. Lines with text stay exactly as they are, unless you tick the option to trim spaces at the end of each line.
Does it handle Windows line endings?
Yes. Windows, Mac and Linux line endings are all handled, and the result uses standard line breaks.
Can I use it on code?
Yes, but be careful with languages where blank lines matter, such as Markdown. Keeping one empty line between blocks is usually safer.
How do I remove blank lines in Excel or Word?
Copy the column or text, paste it here, remove the empty lines, and paste the result back.
Why does copied text have so many blank lines?
Websites, PDFs and email programs often add extra line breaks between paragraphs or list items. When you paste the text elsewhere, those breaks become empty lines that are tedious to delete by hand.
Can I remove empty lines from a CSV file?
Yes. Open the file as text, remove the empty lines, and download the result as a .txt file, then rename it to .csv. Empty rows in a CSV often cause import errors.
Is my text uploaded?
No. The cleaning runs in your browser, so nothing is sent or stored.
How this tool works. These text tools run entirely in your browser with plain JavaScript, so the text you paste never leaves your device and results update as you type. Each tool is tested with real text such as copied PDFs, emails, code, lists, emojis and non-English scripts before it goes live.
Built and reviewed by Hamza Farooq, founder and lead developer
· Last updated
· How we check our tools
· Report a problem