Remove Empty Lines

Remove lines that contain no visible content. A line containing only spaces or tabs is treated as empty and removed.

What this tool actually changes

Each line is tested after trim() is applied only for the emptiness check. Non-empty lines are returned unchanged, so indentation inside meaningful lines is preserved.

Edge cases to know

Whitespace-only lines disappear, but leading or trailing whitespace on non-empty lines remains. Use Trim Whitespace when you also want to normalize those lines.

Example

Input:
alpha

   
beta
  gamma

Output:
alpha
beta
  gamma

Good use cases

Cleaning pasted code fragments, lists, log extracts, generated text, and documentation where blank separators are unwanted.

Check whether blank lines carry meaning

Removing empty lines can make a pasted list or compact export easier to inspect. In source code, Markdown, logs, or records separated by blank rows, those lines may structure or clarify the data. Keep the original when that structure matters.

What counts as empty here?

The tool tests each line with JavaScript trim(). A line consisting of ordinary spaces, tabs, or other whitespace recognized by that method is removed; a line with any remaining character is retained exactly as entered. This is not a test for a particular space character alone.

Complexity and practical limit

The operation checks every character once and retains the non-empty lines in memory. For files too large to paste comfortably, use a local file-processing command so you can review and preserve the source.

Frequently asked questions

What counts as empty?

A line is removed when trim() produces an empty string, so spaces and tabs alone are removed.

Does it remove indentation from real lines?

No. Non-empty lines are returned unchanged.

Should I use Trim Whitespace instead?

Use Trim Whitespace when the goal is to remove leading and trailing whitespace from every line.

Are spaces removed from lines that remain?

No. The trim check determines only whether a line is empty; retained lines are not normalized.

Advertisements