How to use the blank line collapser
- Paste your text into the Text box. The sample is a short email with uneven gaps.
- Set Blank lines to keep in a row, from 0 to 5 (default 1).
- Decide on Treat whitespace-only lines as blank and Remove blank lines at the start and end (both on by default).
- Copy the Collapsed text; Blank lines removed shows how many went.
What it does and when to use it
Extra empty lines creep in when text is copied from PDFs, web pages and chat apps, or when templates leave gaps. They make reviews noisy and documents look broken. This tool keeps your paragraph and section breaks but removes the excess, without touching anything on the non-blank lines.
Code style guides often limit blank lines; Python’s PEP 8, for example, puts two around top-level functions and classes. Set the limit to match. For a fuller tidy-up, the whitespace normalizer fixes trailing spaces and line endings, the line counter shows how many blank lines a file has, and the Python code cleaner limits blank lines while re-indenting.
How it works
The text is split into lines and read from top to bottom in your browser. A counter tracks how many blank lines have appeared in a row:
- While the count is at or below your limit, blank lines are kept.
- Once it goes over, each further blank line is dropped and counted as removed.
- Any non-blank line resets the counter and is copied unchanged.
When trimming is on, blank lines left at the very start and very end are also removed and counted. Lines that hold only spaces are written as truly empty lines when they are treated as blank.
Worked examples
These are the tool’s own outputs.
The sample email, default settings. Three empty lines after “Dear team,”, a gap made of one space line plus one empty line, and three empty lines at the end become:
Dear team,
The release is ready.
Thanks,
Asha
with Blank lines removed: 6.
Limit 0. The same email loses all 8 blank lines and becomes four lines in a row.
Python spacing, limit 2. import os followed by four empty lines and then def main(): keeps exactly two empty lines between them, matching PEP 8. The trailing newline is trimmed, so 3 lines are removed in total.
Space-only lines kept. Between a and b, two lines of three spaces each, with Treat whitespace-only lines as blank unticked: nothing is removed, because those lines are not empty.
Limits and tips
- No awareness of code. Blank lines inside multi-line strings or Markdown code blocks are collapsed too; check those parts.
- Line endings become LF when lines are joined again.
- Leading gaps are kept when trimming is off, but are still cut to your limit.
Frequently asked questions
What counts as a blank line?
How do I remove every blank line?
Why is the last newline gone?
Will it join my paragraphs together?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.