Text cleanup guides

Remove extra blank lines while keeping paragraph breaks

·

A copied route list can have multiple empty lines between headings and stops. Collapse each blank run to one empty line when the gaps still serve as separators. Remove every whitespace-only line when the destination requires one consecutive record per line.

Empty Line Remover

Compare compact and separated layouts on the same input

Select Load example. The sample contains eight physical lines, including four blank lines. In Remove empty and whitespace-only lines, source lines 2, 3, 5 and 6 disappear. The result has four lines, and both Stop entries keep their leading spaces.

Choose Collapse each blank run to one empty line to preserve separators. The results now have six lines. One separator remains after Route A and another after Stop 1. The tab-only line in that second gap counts as part of the same blank run.

Compare compact and separated layouts on the same input
Removal modeLines keptEffect
Remove empty and whitespace-only lines4Removes empty lines and the tab-only line
Remove zero-character lines only5Keeps the tab-only line
Collapse each blank run to one empty line6Keeps a clean separator for each blank run

Keep meaningful spaces on nonblank lines

Leave Trim trailing spaces and tabs off if you need the exact spacing on retained lines. The sample's Stop 1 ends with two spaces. Turning the option on removes just those trailing characters. The two leading spaces before both stops remain.

If this were Markdown, the two trailing spaces could represent a hard line break. Open a downloaded copy in the target editor and compare the rendered paragraph breaks before replacing your original.

CommonMark specification, hard line breaks

Distinguish a blank line from a file’s final newline

A single line ending after Stop 2 closes the last line. An additional line ending creates a trailing empty line. This tool keeps the final line terminator when there is output and the source had one. It writes LF line endings, including when you open a file that used CRLF.

Use Keep one leading blank line or Keep one trailing blank line to retain an edge separator in either removal mode. Collapse mode already keeps one separator per run, including at the edges. Check the rendered result and download cleaned text as a UTF-8 file.

Common questions

Why are two trailing spaces worth keeping in a Markdown document?

Two spaces before a line ending can force a hard line break. Leave trailing-space trimming off where that formatting matters.

Can a line look empty and still survive cleanup?

Yes. A zero-width space is a character that JavaScript does not trim as whitespace. The line stays in the result, even in the whitespace-only mode.

Sources

Put it into practice.

Related guides