DuckyTools
Home Text Trim Whitespace

Trim Whitespace Text

Remove leading and trailing whitespace from every line.

Trim Whitespace is a free online tool that remove leading and trailing whitespace from every line. It runs entirely in your web browser using plain JavaScript, so files are processed on your own device and never uploaded to a server. There is no sign-up, no file size limit imposed by the site, no watermark and no paid tier.

Price
Free — no account, no quota, no watermark
Category
Text
Where it runs
In your browser, on your device
Files uploaded
None
Technology
plain JavaScript
Settings
1
Works offline
Yes, after the first visit

About Trim Whitespace

Leading and trailing whitespace is stripped from each line while whitespace inside the line is left alone. Trailing whitespace is the invisible defect that shows up as a diff on a line nobody touched, breaks Markdown in a way that is genuinely hard to see (two trailing spaces are a line break), and triggers linter failures in CI.

How to use it

  1. Paste the text you want to run through trim whitespace.
  2. Set trim.

The one setting

SettingWhat it doesDefault
TrimChoose from 3: Both ends, Start only, End only.Both ends

Under the hood

Runs onplain JavaScript — runs the whole thing
ControlsTrim

Questions

Does it remove indentation?

Yes — leading whitespace is leading whitespace. If you are cleaning code and want indentation kept, use the trailing-only option.

Why does trailing whitespace matter?

It creates diff noise, changes Markdown rendering, and fails linters. Most editors can show or strip it automatically, and most projects enforce its absence.

What does the trim option change?

It offers 3 choices — Both ends, Start only and End only. The default is Both ends, which suits most cases; change it when your input or your destination calls for something specific.