What is Remove Line Breaks?
A Remove Line Breaks computes remove line breaks from the inputs you provide. It applies the standard formula to the values you enter and returns the result instantly, without sending any data to a server. Strip every newline and carriage return, collapse whitespace, and join multi-line text into one clean line.
Remove Line Breaks
Strip every newline and collapse multiple spaces. Useful when PDF or email pastes carry stray line breaks.
TLDR
Replaces every CR / LF with a space, then collapses runs of whitespace into a single space, then trims. Perfect for cleaning pasted PDF text.
How to use this tool
- Paste your text. Drop in the multi-line content - PDF text, forwarded email, etc.
- Press Remove breaks. Get the entire content joined into a single line with whitespace normalized.
- Copy the result. Paste the clean single-line version where you need it.
- Fix hyphenated wraps manually. Scan for stray hyphens introduced by PDF line breaks ('un fortunately') and remove them.
Real-world scenarios where this tool helps
PDF text cleanup
PDF copy-paste often inserts line breaks at every visual line. Remove them to get continuous paragraphs.
Email forwarding
Outlook and Gmail wrap text at ~78 chars when forwarded. Strip the breaks to restore the original flow.
Spreadsheet imports
Excel chokes on multi-line cell content. Single-line your inputs first.
CSV preparation
If a column has stray newlines from a source system, this lets you remove them before saving as CSV.
Code comment normalization
Convert a multi-line code comment into one long string for git commit messages.
What this tool does
- Replaces every newline (\n) and carriage return (\r) with a single space.
- Collapses runs of whitespace - tabs, multiple spaces, mixed - into one space.
- Trims leading and trailing whitespace from the final result.
- Preserves all letters, digits, punctuation, and Unicode characters.
- Works on any length text your browser will hold.
What it does NOT do
- Does not preserve paragraph boundaries - everything becomes one line.
- Does not insert sentence-ending periods if your source lacked them.
- Does not fix hyphenated line breaks ('un-\nfortunately' becomes 'un fortunately' with a space).
- Does not save anything to a server.
- Does not split on word boundaries - it works at the whitespace level only.
About line-break removal
Pasted text from a PDF, an email forward, a webview, or a chat window often arrives with line breaks every 60 to 80 characters because that is the visual width of the original. The text is supposed to be one paragraph, but the visible breaks were baked in by whichever renderer produced the source. Pasting that broken-up text into a form field, a tweet, or a single-line spreadsheet cell looks ragged. This tool flattens the entire input into one continuous string, with all whitespace runs collapsed to single spaces and the ends trimmed.
The transform is destructive but deterministic. The same input always produces the same single-line output, and the only thing that gets lost is the line-break structure itself; letters, digits, punctuation, and Unicode characters are preserved byte for byte. If you care about paragraph boundaries, mark them with a placeholder before running, then restore.
How the algorithm works
return input
.replace(/[\r\n]+/g, ' ') // every CR/LF -> space
.replace(/\s+/g, ' ') // collapse runs of whitespace
.trim(); // strip leading/trailing
Two regex passes and a trim. The first replaces every run of CR and LF with a single space; the second collapses any remaining whitespace runs (mixed tabs, multiple spaces, the spaces just introduced); the trim cleans the edges. Time complexity is O(n) and the operation streams through the string in one pass per regex.
Worked example
Input (a paragraph copy-pasted from a 70-column PDF):
The quick brown fox jumps over the lazy dog. The dog barks and the fox runs away to a clearing in the forest beyond the river.
Each visible line ends with a CR or LF, but the text is one continuous sentence. The tool replaces every break with a space, collapses any runs, then trims. The output joins seamlessly.
What each character does
| Input | After pass 1 | After pass 2 | Final |
|---|---|---|---|
| letter "a" | a | a | kept |
| line feed \n | space | collapsed | single space |
| CR + LF \r\n | space | collapsed | single space |
| tab \t | tab | space | single space |
| 3 spaces | 3 spaces | 1 space | single space |
| leading/trailing whitespace | same | same | trimmed |
| non-breaking space U+00A0 | same | matched by \s | collapsed |
Common mistakes and pitfalls
- Running on poetry or code. Line breaks are the format. You will get a single line of unreadable mush.
- Forgetting hyphenated wraps from PDF. A break in the middle of a word like
un-\nfortunatelybecomesun fortunately. Fix with a regex that removes-before joining. - Using on structured CSV. A multi-row CSV becomes one giant single row with no separators. Use a CSV-aware parser instead.
- Joining a chat transcript. Speaker labels and message boundaries vanish. Mark them with markers (
>>,::) first. - Pasting Markdown source. Headings, lists, fenced code blocks all flatten. Convert to HTML first if you need to preserve structure.
- Forgetting it runs once. The tool does not re-run on its own output. If you paste something pre-cleaned, the second pass changes nothing, which is intentional.
Related tools
Frequently asked questions
What is the difference between this and Remove Empty Lines?
This tool collapses every break into one line, producing a single continuous string. Remove Empty Lines keeps the line structure intact and only drops the blank rows between content. Use this tool when you want a one-liner; use the other when you want compact but still multi-line output.
Will it handle Windows CRLF?
Yes. Both the carriage return (\r) and the line feed (\n) are matched and replaced, so Windows CRLF, Unix LF, and the rare old-Mac CR-only files all flatten correctly.
What happens to tabs?
Tabs are whitespace, so they get collapsed into a single space along with any newlines and runs of spaces. If a line contained a tab-separated table, it becomes space-separated and is no longer machine readable as TSV.
Can I preserve paragraph breaks?
Not with this tool. It strips all breaks unconditionally. For paragraph-preserving cleanup, replace double newlines with a placeholder first, run this tool, then restore the placeholder, or use a Markdown-aware reflow tool.
Will it fix hyphenated breaks from PDF?
Partially. A PDF break that produced 'un-\nfortunately' becomes 'un fortunately' with a space, not the joined 'unfortunately' you probably want. You will still need a search-and-replace pass for the leftover space-after-hyphen pattern.
Does it work on Markdown?
It runs, but it will flatten your Markdown into one long line. Headings, lists, code blocks, and paragraph breaks all collapse to plain text. Do not use this on Markdown you want to preserve as Markdown.
Will it handle very long pastes?
Yes. The operation is two regex replacements on the full string and runs at native browser speed. A 1 MB paste (roughly a 200,000-word document) finishes in well under a second on a modern laptop. The browser textarea is usually the slower component.
