Whitespace Remover
Strip line breaks, extra spaces or both.
About Whitespace Remover
A whitespace remover strips line breaks, collapses blank lines and runs of spaces, and trims each line. Pick any combination of the four options.
How to use
- Paste the text. The cleaned version appears on the right as you type.
- Tick or untick the options; all but "Collapse blank lines" are on by default.
- Check the line counts before and after, then Copy or Download
cleaned.txt.
Options
| Option | What it does |
|---|---|
| Remove line breaks | Replaces every run of newlines (\n or \r\n) with a single space, joining the text into one line |
| Collapse blank lines | Replaces runs of blank lines with a single blank line. Only available while line breaks are kept |
| Collapse runs of spaces and tabs | Replaces runs of two or more spaces or tabs with one space; a single tab is left alone. Newlines are never touched |
| Trim leading and trailing spaces | Removes whitespace at both ends of each line, or of the whole text when lines were joined |
- Order is fixed: line breaks first, then collapsing, then trimming.
- With only "Remove line breaks" on, a blank line becomes one space and leading indentation is kept.
- Does not remove non-breaking spaces (U+00A0) when trimming or collapsing is off, and does not reflow minified code into readable lines.
Example
First line
second line with tabs
→ all three options
First line second line with tabs
Privacy
Cleaning runs in the browser. No request is made, and nothing is stored.
Frequently asked questions
- How do I remove all line breaks from text?
- Replace every newline character with a space, then collapse any doubled spaces. In this tool that is the default: "Remove line breaks" and "Collapse repeated spaces" together turn a multi-line paste into one line.
- What counts as whitespace?
- In JavaScript the \s class matches the space, tab, newline, carriage return, form feed, vertical tab and Unicode space separators including the non-breaking space (U+00A0). The collapse and trim options use that definition.
- Why do copied PDFs have a line break after every line?
- PDF stores text as positioned lines, so copying keeps the visual line endings as hard newlines. Removing line breaks and collapsing spaces reflows the text into normal paragraphs.