Text desk

Trim Lines

Remove surrounding whitespace from every line without changing line order.

Trim Lines: Clean the edges of each pasted line by removing leading and trailing whitespace. Trim Lines leaves spaces between words alone, preserves the list order and keeps blank entries as blank entries. Use it for labels or identifiers copied with unwanted padding, provided indentation is not meaningful. Runs 100% locally in your browser with zero server file uploads.

Category
Text tools
Runs
In your browser
Cost
Free · no sign-up
Availability
Ready to use
Trim Lines / local editorLocal processing

Runs entirely in your browser

100,000 character input · 10,000 logical lines · 200,000 character output

Result

Ready

Text is processed locally. The tool uses literal, allowlisted operations and does not execute regular expressions or code.

Edge-removal rule and exact result

Let L be one logical line, P its longest leading whitespace sequence and S its longest trailing whitespace sequence. The output line is L with P and S removed, keeping the middle unchanged. With input 12 \r\n\t34\t\r\n \r\n, the three entries become 12, 34 and an empty entry. The exact output is 12\n34\n\n: three logical lines and the preserved final LF. Trimming the third entry does not delete it. Use the Unicode inspector to examine hidden characters and remove extra spaces if internal spacing also needs attention.

Boundaries, Unicode and capacity

ECMAScript defines the edge whitespace set (https://tc39.es/ecma262/multipage/text-processing.html#sec-string.prototype.trim); it includes more than the ASCII space. The line splitter recognises LF, CRLF and bare CR, and the result uses LF. Unicode line separator U+2028 is not a logical-line delimiter here, although edge trimming can remove it. A request accepts at most 100,000 input code points and 10,000 lines, with output capped at 200,000 code points. Trimming changes no sort order or language collation. Browser fields count UTF-16 units for their length allowance, so a supplementary character can occupy two input places.

How to use it

  1. Paste or type your lines in the local editor.
  2. Set the options shown for this transformation and run it.
  3. Review the result, then copy or download the text.

Privacy & limitations

Your text and result stay on this device. There is no upload or execution of entered code.

Related tools

Frequently asked questions

Will this collapse repeated spaces between words?

No. The two spaces in red apple remain two spaces when they are inside the line. Only whitespace touching either edge is removed. Tabs between columns also remain, so trimming does not turn a tab-separated record into a single-spaced sentence.

Why does an invisible character remain at an edge?

Not every invisible character is whitespace under the trimming rules. U+200B zero-width space remains, while U+00A0 non-breaking space is removed at an edge. Accents and combining marks are preserved. This is not Unicode normalisation or a method for detecting look-alike identifiers.

Should I trim indented source code or Markdown?

Usually only after checking its structure. Leading spaces can encode nesting or code blocks, and trailing spaces can be deliberate in text formats. The tool cannot distinguish layout padding from meaningful whitespace. Copy a small section first and compare it with the original before applying it widely.

Free tool · runs in your browser · no account required