Trim Lines
Remove the spaces and tabs at the start and end of each line of a list or block of text.
Processed locally in your browser· Your data stays in your browser.
What is Trim Lines?
Trimming works line by line: it strips whitespace at the beginning (left trim), at the end (right trim) or both, and leaves the line breaks alone. It fixes copied lists with stray indentation, trailing spaces that break comparisons and sloppy exports.
Choose which side to trim, and optionally collapse runs of spaces inside each line into one. Indentation is removed only when you ask for it, so trimming only the trailing side keeps code-style indentation intact.
How does it work?
- Paste the lines you want to clean.
- Select trimming on both ends, at the start only, or at the end only.
- Tick "collapse repeated spaces inside lines" if needed, then copy the result.
Common use cases
- Removing trailing spaces from code or configuration before committing.
- Cleaning a list of values pasted from a spreadsheet before deduplicating it.
- Stripping indentation from copied Markdown or e-mail text.
- Normalizing lines before comparing two texts.
Examples
Try this input in the tool above:
indented line Tabbed many inner spaces clean
indented line Tabbed many inner spaces clean
Privacy
Trim Lines runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.
Limitations
Only whitespace at the ends (and optionally repeated inner spaces) is affected. Empty lines stay in place; use Remove Empty Lines to delete them.
Frequently asked questions
How is this different from Remove Extra Spaces?
Trim Lines is focused on line boundaries and lets you choose the left or right side. Remove Extra Spaces is a broader whitespace cleaner with blank-line and punctuation options.
Are tabs and non-breaking spaces trimmed?
Yes. Tabs, non-breaking spaces and other Unicode whitespace at line ends are removed.
Related tools
Remove Extra Spaces
Clean up spacing in pasted text: double spaces, stray tabs, trailing spaces and runs of blank lines.
Text Tools
Remove Empty Lines
Strip blank lines from pasted text in one click, or keep a single blank line between paragraphs.
Text Tools
Text Cleaner
Sanitize text copied from the web, documents or AI chats: invisible characters, curly quotes, odd spaces and Unicode quirks, each step under your control.
Text Tools
Add Prefix / Suffix to Lines
Put the same text at the start and end of each line, or number the lines automatically.
Text Tools
Remove Duplicate Lines
Paste a list and keep only unique lines, in the original order or sorted, with a count of what was removed.
Text Tools
Sort Lines
Order any list one item per line: A to Z, Z to A, natural, numeric or by length.
Text Tools