Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

Remove Empty Lines and Blank Lines

Delete blank lines or squeeze them down to one.

Removed 0 empty lines

Use via API

Remove blank lines from text, or collapse runs of blank lines into one. Send JSON, get JSON back.

POST https://pithlab.com/api/v1/tools/remove-empty-lines

curl https://pithlab.com/api/v1/tools/remove-empty-lines \
  -H "Authorization: Bearer $PITHLAB_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":"First line\n\n\nSecond line\n   \nThird line"}'

Fields and responseOpenAPI documentGet an API key

About the Remove Empty Lines

Delete blank and whitespace-only lines from text, or collapse runs of empty lines into one. Keeps your line endings and works instantly in the browser.

How to use the Remove Empty Lines

  1. Paste your text into the input box.
  2. Choose whether lines containing only spaces or tabs count as empty.
  3. Tick Keep one blank line between blocks to collapse gaps instead of removing them completely.
  4. Copy the cleaned text or download it as a file.

Examples

Remove every blank line

Input

First


Second
   
Third

Output

First
Second
Third
Collapse gaps to a single blank line

Input

Para one



Para two

Para three

Output

Para one

Para two

Para three

Frequently asked questions

What counts as an empty line?

A line with no characters at all. With Treat whitespace-only lines as empty switched on, which is the default, lines containing only spaces, tabs or other invisible whitespace are removed too.

Will it change the rest of my text?

No. Non-blank lines are kept exactly as written, including indentation, and Windows (CRLF) line endings are preserved.

What does collapsing do?

Collapsing replaces each run of blank lines with exactly one, which keeps paragraphs separated while removing extra gaps. Blank lines at the very start and end are removed.