Trim line whitespace
Trim leading and trailing spaces and tabs from every line, optionally dropping lines that become empty — with LF output and counts of rewritten and removed lines.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Only leading and trailing spaces and tabs are removed; spaces inside a line stay. CRLF, CR and LF are recognised and the output uses LF.
Result
The "rewritten lines" figure counts lines whose surrounding whitespace really changed.
Enter text to process
Input lines: 0 · Rewritten: 0 · Removed: 0
What this tool does
- Clean up table text copied from Excel or a PDF before splitting it into columns
- Remove the indentation spaces that come along when pasting code or config snippets
- Normalise leading and trailing tabs across a batch of lines
Example
Input
a b
Output
a b
Blank lines are kept by default: both lines lose their surrounding whitespace, characters inside stay put and the rewritten count is 2.
Frequently asked questions
What does the preserveEmpty switch do?
It is on by default, so the tool only trims and blank lines stay. Turning it off also deletes lines that become empty after trimming (lines that held only spaces or tabs), giving you "trim + drop blank lines" in one step — the removed count then becomes greater than zero.
Are spaces inside a line removed?
No. Only the leading and trailing whitespace of each line is touched (spaces, tabs and other whitespace except \n), so extra spaces used between words survive: "a b" stays "a b".
How are newlines and line counts handled?
CRLF, CR and LF are all recognised and the output uses LF. The input line count is the number of split segments: empty input is 0 lines, while "a\n" is 2 lines because the trailing empty segment counts. The rewritten count only includes lines whose surrounding whitespace actually changed.
Keywords:trim linestrim whitespacetxt-trim