Trim Text
Trim leading and trailing spaces from text or every line.
Options
Trimmed text
How to trim text
Paste your text into Your text, or press Load example to try this sample:
padded lines indented here trailing
Pick a Side (Both, Left or Right) and a Scope (Every line or Whole text
only). The trimmed version appears next to it and updates as you type. Copy the result or download it
as a .txt file. Everything runs in your browser, so nothing you paste is uploaded.
Examples
| Input | Output |
|---|---|
| padded lines | padded lines |
| indented here | indented here |
| a b | a b |
Limits and edge cases
- Whitespace follows JavaScript trim rules: spaces, tabs, non-breaking spaces and other Unicode whitespace at the selected edges are removed, while inner spacing is never touched.
- Windows (CRLF) line endings are preserved: the trailing carriage return stays as the line ending and only spaces and tabs around each line are trimmed.
- Scope matters: Every line trims the start and end of each line separately, while Whole text only trims the very beginning and end of the entire input and keeps padding on inner lines.
Frequently asked questions
How do I trim spaces from text?
Paste your text into the input box, pick a side and a scope, and the trimmed result appears instantly. Copy it or download it as a .txt file.
What is the difference between Every line and Whole text only?
Every line trims the start and end of each line separately, while Whole text only trims the very beginning and end of the entire input and leaves padding on inner lines untouched.
Can I trim only leading or only trailing spaces?
Yes. Choose Left to remove leading whitespace only, Right to remove trailing whitespace only, or Both to remove both sides.
Are tabs removed too?
Yes. Trimming uses JavaScript trim rules, so spaces, tabs and other whitespace at the selected edges are removed.
Are Windows line endings preserved?
Yes. CRLF line endings are preserved: the carriage return stays as the line ending and only spaces and tabs around each line are trimmed.
Is my text uploaded anywhere?
No. Trimming runs in your browser with JavaScript and nothing is sent to a server. Inputs under 200 KB are kept in your browser's local storage so they are still there when you come back.