How to use Trim Lines
- Paste your text into Your text.
- Pick what to Trim: Both ends, Start only or End only.
- Copy the cleaned text from the result.
What it does and when to use it
Invisible whitespace at the edges of lines causes real problems. Two names that look the same do not match in a spreadsheet lookup because one has a trailing space. A list pasted from a web page is pushed to the right by leading tabs. Code review tools flag every line that ends in spaces.
Choose the option for the job:
- Both ends is for lists and data: names, email addresses, product codes, IDs. Each value ends up tight, so sorting and matching work as expected.
- Start only removes indentation, for example from a block quote or a text copied out of a nested list, while leaving line endings alone.
- End only is for code, Markdown and config files. It clears trailing spaces but keeps the indentation that gives the text its structure.
Note that in Markdown, two spaces at the end of a line can mean a line break, so End only removes those breaks too.
Trimming fits well before other list tools. After it, remove duplicate lines so that “anna” and “anna “ count as the same, or sort the lines so indented entries do not jump to the top.
How it works
The text is split at each line break. Each line is passed through the browser’s built-in trim function for the side you chose (trim, trimStart or trimEnd), and the lines are joined again in their original order. Nothing else in the line changes, and the text never leaves your device.
Worked examples
The first two examples use three lines: “ Name “ (spaces on both sides), a tab + “Age” + a tab, and “ City”.
Both ends. Every line is cleaned on both sides, giving Name, Age and City on three lines.
Start only. Leading spaces and tabs go, trailing ones stay. “Name” keeps its three trailing spaces and “Age” keeps its trailing tab, while “City” has nothing left to trim at the end.
End only, for code. A two-line Python snippet where the second line ends in three stray spaces. End only gives def f(): and return 1: the 4- and 8-space indents are untouched and the trailing spaces are gone.
Limits and tips
- Spaces in the middle of a line are left alone. Pair this with Remove Extra Spaces for a full clean-up.
- To convert indentation rather than remove it, use Tab to Spaces.
Frequently asked questions
Does trimming remove spaces between words?
Which characters count as whitespace?
Will it delete empty lines?
How do I clean code without losing indentation?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.