Skip to content
TextArray
100% local

Trim lines

Remove leading and trailing whitespace from each line of your text.

Input
Output

Trim lines

Whitespace at the start and end of lines is often invisible but clutters code, data exports and copy–paste results. Paste any text and this tool removes spaces and tabs from the edges of every line while keeping all internal spacing and line breaks intact. " hello world " becomes "hello world" on each line, instantly.

Choose how much to trim. Both sides removes whitespace from the start and end of each line, which is the most common cleanup. Leading only removes spaces before the text, useful when you need to preserve right-alignment or trailing indentation. Trailing only removes spaces after the text, perfect for cleaning up lines that have accidental whitespace tails from export systems or sloppy pasting.

The number of lines stays exactly the same, including blank lines. Windows and Unix line endings are handled identically. The live tally shows how many whitespace characters were removed and how many lines the result has, so you can see the impact of each choice instantly.

Everything runs locally in your browser, so no text is sent anywhere. This makes the tool safe for cleaning up code snippets, SQL queries, CSV exports, log files or any text with invisible whitespace issues. Copy the result, download it as a .txt file, or send it to another tool when you are done.

FAQ

Why would I trim whitespace from lines?
Pasted text often has stray spaces before or after each line from copy-paste errors or export formatting. Trimmed code compiles without whitespace-related failures. CSV and database imports reject lines with trailing spaces.
Does trimming remove internal spaces?
No. Internal spaces within the line are always preserved. Only the whitespace at the very start (leading) and very end (trailing) is removed when you choose to trim those sides.
What counts as whitespace?
Both spaces (ASCII 32) and tabs (ASCII 9) are trimmed. Other characters like newlines, punctuation and letters are never touched.
Will my blank lines disappear?
No. Blank lines stay blank and the line count does not change. Only the edges of non-empty lines are cleaned.
Is my text uploaded anywhere?
No. The tool runs entirely in your browser and your text never leaves your device.