Skip to content
PithLab

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

Remove Empty Lines API

Remove blank lines from text, or collapse runs of blank lines into one.

POST /api/v1/tools/remove-empty-linesMCP remove_empty_linesText & Writing

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.

Input

Send these as a JSON object. Unknown fields are rejected.

input
The text. (string, required)
whitespaceOnly
Count lines containing only spaces or tabs as empty. (boolean, default true)
collapse
Keep a single blank line where several were (and drop blank lines at the start and end) instead of removing them all. (boolean, default false)
curl https://pithlab.com/api/v1/tools/remove-empty-lines \n  -H "Authorization: Bearer $PITHLAB_KEY" \n  -H "Content-Type: application/json" \n  -d '{"input":"First line\n\n\nSecond line\n   \nThird line"}'
Example response
{
  "ok": true,
  "result": {
    "output": "First line\nSecond line\n   \nThird line",
    "total": 6,
    "removed": 2
  }
}