TT · TEXT TIDY

GUIDE · SPACING

Removing blank lines without breaking your document

By ShengFeng · Published 2026-10-10 · Last updated: 2026-10-15

Blank lines are the cheapest defect to fix and the easiest one to fix wrongly. In a pasted list they are noise; in a Markdown file they are the difference between two paragraphs and one. This guide explains exactly what the action treats as blank, shows what it does to a real document, and lists the cases where you should not run it at all.

What counts as a blank line

A line is blank when its trimmed content is empty. Trimming removes ordinary spaces and tabs, and it also removes the Unicode space separators — which is why a line that looks blank because it is made of non-breaking spaces is removed too, even though that character is not an ordinary space. What trimming does not remove are the invisible format characters, and that is the source of most “why will this line not go away?” questions.

Lines that are removed and lines that survive
Line contains Removed as blank? Why
Nothing at all Yes Empty string
Spaces only Yes Trim removes spaces
A tab Yes Trim removes tabs
A non-breaking space (U+00A0) Yes Trim removes Unicode space separators
A zero-width space (U+200B) No A format character, not whitespace — trimming leaves it
A soft hyphen (U+00AD) No Also a format character
A byte order mark (U+FEFF) Yes, at the line edge Included in the whitespace set for trimming

Before and after

A pasted list with a mix of genuinely empty rows and rows that contain only whitespace:

Quarterly tasks

  	 
Draft the summary
Circulate for comment


Publish the summary

After Remove blank lines, all four empty rows are gone in a single pass and the four content rows close up. Nothing else changes — no surviving line is trimmed, reordered or joined:

Quarterly tasks
Draft the summary
Circulate for comment
Publish the summary

Blank lines that carry meaning

In several plain-text formats a blank line is not decoration; it is syntax. Removing them changes how the file behaves, not just how it looks.

The practical rule: remove blank lines when the blank lines are an artefact of copying, and leave them when they are part of the document's structure. If you are not sure which you have, keep a copy of the original — the input panel is not modified, so copying the input out before you transform it costs nothing.

Why a blank line sometimes survives

The most common reason is a character that looks like nothing but is not whitespace. A zero-width space, a zero-width joiner or a soft hyphen all render as no visible mark, and none of them is removed by trimming, so a line consisting only of one of those characters is technically not empty. The counters give you the clue: if the line count does not drop as much as the visible blank lines suggest, or the character count stays high for a line you believe is empty, an invisible character is almost certainly present. The invisible characters guide covers how to find them.

The second reason is simpler: the action removes lines, not whitespace. A row containing a space, or a tab, is a row that the earlier step has not yet emptied. Cleaning spacing before removing blank lines avoids the whole problem.

A sequence for cleaning a pasted document

  1. Copy the input out first if the original matters. The panel is not saved for you.
  2. Run Remove blank lines. Every row whose trimmed content is empty goes in a single pass, including rows that hold nothing but spaces or tabs.
  3. Run Clean spacing. This trims the surviving lines, which is a separate job: removing blank lines never trims what it keeps.
  4. Restore the structure you need. In Markdown, put back the paragraph breaks; in a list, confirm that one item per line is what you have.
  5. Check the line count. The difference between the before and after counts is exactly the number of rows removed — a useful audit number.

Common mistakes

If you are unsure whether a particular blank line was doing work, there is a cheap test. Look at the line count before and after and ask whether the drop matches the number of empty rows you could actually see. If the count fell by more than that, something non-blank disappeared as well — which is the signal to restore the input and work on a copy instead.

Frequently asked questions

Does removing blank lines trim the lines that remain?

No. It removes lines and nothing else. Leading spaces and tabs on the surviving lines stay exactly as they were. Run Clean spacing if you want them trimmed.

Is a row containing only spaces removed?

Yes. Each line is trimmed before the check, so a row made of spaces, tabs or non-breaking spaces counts as empty and disappears. Only a character that is not whitespace — such as a zero-width space — keeps a row alive.

Why is a blank line still there after I removed blank lines?

It almost certainly contains a character that is not whitespace — most often a zero-width space or a soft hyphen. Those render as nothing and survive trimming. Use the character count to confirm, then remove the character itself.

Will this break my Markdown file?

It can. In Markdown a blank line separates paragraphs, so removing blank lines merges adjacent paragraphs when the file is rendered. If the file is Markdown, do not run the action on the whole document.

Does it affect the word count?

No. Blank lines contain no words. Only the line count changes, by exactly the number of rows removed.

← All guides