>Fafa Dev Tools

Trim Whitespace

Trim leading and trailing whitespace, trim each line, and collapse multiple spaces. Free online whitespace trimmer with customizable options.

0 chars
Output will appear here...

What is Trim Whitespace?

Whitespace includes spaces, tabs, and newlines that are invisible but affect text formatting. Trimming whitespace removes leading and trailing spaces from text or individual lines, and can collapse multiple consecutive spaces into one. This is useful for cleaning up copied text, form data, CSV files, and user input before processing.

How to Use

  1. Paste your text with extra whitespace in the input area
  2. Toggle 'Trim start & end' to remove whitespace at the beginning and end of the entire text
  3. Toggle 'Trim each line' to remove leading and trailing spaces from every line
  4. Toggle 'Collapse multiple spaces' to convert runs of spaces into a single space

Examples

Trim all whitespace

Input Hello World Foo Bar
OutputHello World Foo Bar

Collapse spaces only

InputToo many spaces here
OutputToo many spaces here

Frequently Asked Questions

What whitespace characters are trimmed?

The tool trims spaces, tabs, and other whitespace characters from the start and end of lines. Newlines between lines are preserved — only leading and trailing whitespace on each line is removed.

Does collapsing spaces affect indentation?

Yes. If you enable 'Collapse multiple spaces' and 'Trim each line', code indentation will be removed. Use this option for prose text, not for code where indentation is meaningful.

Can I use this to clean up copied text?

Yes. Text copied from websites, PDFs, and emails often contains extra whitespace. Enable all three options to get clean, compact text ready for processing or publishing.