Trim whitespace from each line, remove extra spaces between words, and clean up messy text formatting. Fix inconsistent spacing in your text instantly.
This example demonstrates whitespace cleanup from String Tools, pre-loaded with text containing leading, trailing, and extra spaces. Paste any text and clean up formatting issues instantly.
The tool processes your text line by line, removing unwanted whitespace. Each line is trimmed independently, so leading spaces on one line do not affect others. The result is clean, consistently formatted text.
| Mode | What It Does |
|---|---|
| Trim Left | Removes leading spaces and tabs from each line |
| Trim Right | Removes trailing spaces and tabs from each line |
| Trim Both | Removes both leading and trailing whitespace |
| Collapse Spaces | Reduces consecutive spaces within a line to a single space |
Invisible whitespace characters cause problems that are hard to detect:
When copying text from PDFs, websites, or word processors, invisible characters often sneak in: non-breaking spaces, zero-width spaces, and soft hyphens. The tool handles standard whitespace. For exotic Unicode whitespace, use the find-and-replace tool with a regex character class targeting specific Unicode ranges.
If you trim leading whitespace from code, indentation is removed. Use the trim-right option for code to preserve indentation while removing trailing spaces. For mixed indentation issues, a proper code formatter is more appropriate.
Yes. Select the collapse-spaces option to reduce multiple consecutive spaces to a single space. This preserves single spaces while eliminating runs of two or more spaces. It does not affect leading or trailing whitespace unless combined with a trim mode.
Tabs at the beginning of lines are treated as leading whitespace and removed in trim-left mode. Tabs between words are preserved as single characters. To convert tabs to spaces first, use the find-and-replace tool with tab matching.
Nothing you paste leaves this tab. Every tool runs entirely in your browser — no upload, no server, no account.