All Tools
Categories
Email Marketing Tools 13 Text Tools 12 Marketing Tools 3 Encoder Tools 1 Security Tools 1 Generator Tools 1
About Contact Privacy

Trim Text

Trim text by removing leading, trailing, and extra whitespace. Collapse multiple spaces, strip tabs, remove indentation, truncate lines, and clean invisible characters. Free online tool.

Trim Mode
chars (0 = off)
0 Chars Before 0 Chars After 0 Chars Removed 0 Lines

About Trim Text

Trim Text is a free online whitespace cleaning tool that removes unwanted spaces, tabs, indentation, and invisible characters from your text. Whether you've copied text from a PDF with ragged spacing, need to normalise indentation in code, or want to clean up form data — this tool handles it in one click.

It goes beyond basic trimming with modes for leading-only, trailing-only, and per-line trimming, plus advanced options for collapsing multiple spaces, converting tabs, removing invisible Unicode characters, truncating lines, and stripping specific characters. Everything runs locally in your browser.

Features

  • Trim both sides: Remove leading and trailing whitespace from each line
  • Trim leading only: Remove whitespace from the start of each line (preserves trailing)
  • Trim trailing only: Remove whitespace from the end of each line (preserves indentation)
  • Collapse spaces: Replace multiple consecutive spaces with a single space
  • Remove all spaces: Strip every space character from the text
  • Tab handling: Convert tabs to spaces (configurable width) or remove all tabs
  • Remove invisible characters: Strip zero-width joiners, non-breaking spaces, byte order marks, and other hidden Unicode
  • Remove indentation: Strip common leading whitespace from all lines (like code dedent)
  • Truncate lines: Limit each line to a maximum character length with optional ellipsis
  • Strip specific characters: Enter custom characters to remove from the entire text
  • Live statistics: Characters before/after, spaces removed, lines count

How to Use

  1. Paste your text: Enter or paste text with whitespace issues into the input area.
  2. Choose a trim mode: Select Trim Both, Trim Leading, Trim Trailing, Collapse Spaces, or Remove All Spaces.
  3. Set additional options: Toggle tab conversion, invisible character removal, truncation, or enter custom characters to strip.
  4. Click Trim: The cleaned result appears instantly in the output area.
  5. Copy or download: Grab the result with one click.

Examples

Trim Both:
Input:    Hello World    → Output: Hello World

Collapse Spaces:
Input: Hello     World   Foo → Output: Hello World Foo

Remove Indentation (Dedent):
Input:
    if (true) {
        return;
    }

Output:
if (true) {
    return;
}

Truncate to 20 chars:
Input: This is a very long line of text → Output: This is a very long…

Benefits

  • Clean pasted content: Remove extra spacing from PDF, Word, or web page copies
  • Normalise code indentation: Dedent, convert tabs, or standardise spacing
  • Data cleaning: Strip invisible characters that break parsers, comparisons, and imports
  • Multiple modes: Fine-grained control over exactly which whitespace to remove
  • Instant and private: Runs in your browser, no upload, no server processing
  • Free and unlimited: No account, no limits on text size

Frequently Asked Questions

What does trimming text mean?
Trimming removes unwanted whitespace characters (spaces, tabs, line breaks) from text. You can trim the start, end, or both sides of the entire text, or trim each individual line, depending on the mode you select.
What is the difference between Trim and Collapse Spaces?
Trim removes spaces from the edges (start/end) of text or lines. Collapse Spaces replaces multiple consecutive spaces within the text with a single space — for example, 'hello world' becomes 'hello world'. You can use both together.
Can I remove only leading or only trailing spaces?
Yes. The tool has separate modes for Trim Both, Trim Leading (left side only), and Trim Trailing (right side only). These apply to each line individually.
Does this tool handle tabs and special whitespace?
Yes. You can convert tabs to spaces, remove all tabs, strip non-breaking spaces (\u00A0), zero-width characters, and other invisible Unicode whitespace.
Can I truncate lines to a maximum length?
Yes. Use the Truncate Lines option to set a maximum character count per line. Lines longer than the limit are cut, optionally with an ellipsis (…) appended.
Is my text sent to a server?
No. All trimming happens in your browser using JavaScript. Your text is never transmitted or stored.