FileGizmo Text tools
Trim whitespace and remove blank lines
Strip leading and trailing spaces from every line, remove or collapse blank lines, and reduce runs of spaces and tabs inside them. Nothing is uploaded.
Complete
Your result is ready
Simple by design
Trim whitespace in three steps
This is the most common text cleanup there is, and the one people most often do by hand: pasted text arrives with indentation from wherever it came from, trailing spaces nobody can see, and blank lines wherever the original had a page break.
Trimming itself is simple, and the tool lets you choose which ends to trim. Both ends is the usual answer. Leading only is what you want when trailing spaces are meaningful, as they are in some fixed-width formats. Trailing only is what you want when the indentation is real structure, as in code or YAML, but invisible trailing whitespace is causing a diff to show changes that are not there.
The interesting decision is what counts as a blank line. A line containing three spaces is blank to a reader and not blank to a simple equality test, so a tool that checks for emptiness before trimming leaves those lines in place. Every one of them then survives as an invisible artefact of whatever produced the text. FileGizmo trims first and checks afterwards, so a line holding only spaces and tabs is treated as what it looks like.
What should happen to those blank lines is a real choice rather than a preference. Deleting all of them produces a dense block, which is right for a list of values and wrong for prose, because the paragraph breaks were the blank lines. Collapsing runs of blank lines down to one keeps every paragraph break while removing the double and triple spacing that comes out of a PDF or an email client. Keeping them all is there for when only the horizontal whitespace was the problem.
The optional run-collapsing setting reaches inside each line and reduces any sequence of spaces and tabs to a single space. This is the setting to use for text copied out of a rendered document, where columns of alignment spaces come along with the words. It is the setting to leave alone for code, where the interior spacing is the indentation.
The result reports how many lines were trimmed, how many blank lines were removed, and how many lines are left, so it is possible to tell a run that did nothing from a run that did too much. Nothing is uploaded, and the text stays in this tab.
- 1
Paste text with stray indentation or blank lines
- 2
Choose which ends to trim and what should happen to blank lines
- 3
Press Trim whitespace and copy or download the result
Good to know
Frequently asked questions
Is a line of three spaces a blank line?
Yes. The blank check runs after trimming, so a line holding only spaces or tabs counts as blank. Checking before trimming is the common mistake, and it leaves invisible lines behind.
What is the difference between removing and collapsing blank lines?
Removing deletes every blank line, which also deletes the paragraph breaks. Collapsing keeps a single blank line wherever there were several, so paragraphs survive while double and triple spacing does not.
Will this join my wrapped lines together?
No. This tool works line by line and never joins two lines. To reflow wrapped text into paragraphs, use Remove line breaks or Wrap text instead.
Does it change what is inside the line?
Only if you ask it to. The optional run-collapsing setting reduces runs of spaces and tabs inside a line to one space; otherwise the interior of each line is untouched.
Learn more