Remove Line Breaks
Paste text with line breaks below, they're instantly joined into a single flowing block, with your choice of replacement.
About the Remove Line Breaks Tool
Line breaks in pasted text get replaced with a space, comma, or nothing at all, joining everything into one continuous block. Useful for text copied from PDFs or emails where breaks land in odd spots, or when a field only accepts a single line.
All three line-ending styles are recognized, and the order they're checked in matters
The splitting pattern is /\r\n|\r|\n/, covering Windows-style CRLF, old classic Mac-style lone CR, and Unix-style lone LF line endings in one pass. The order inside that alternation isn't arbitrary: regex alternation tries each option left to right and stops at the first match, so checking for the two-character \r\n sequence before the single \r is what prevents a Windows-style line break from being incorrectly split at just the carriage return, which would otherwise leave a stray, unconsumed \n character sitting at the start of the next segment. Putting the longer, more specific pattern first is what makes this correctly handle text regardless of which operating system or application it was originally created on.
The "collapse spaces" option only cleans up literal spaces, not comma-separated results
When "collapse multiple resulting spaces into one" is checked, it runs / {2,}/g against the joined result, which only matches runs of two or more literal space characters. That works well when the replacement is a single space, cleaning up the extra spaces that appear when multiple consecutive line breaks (a blank line between paragraphs) get joined back to back. But if "Comma + space" is selected as the replacement instead, a blank line produces a comma, then an empty joined segment, then another comma and space — something like "line one, , line two" — and the collapse option won't touch that, because there's no run of two or more literal spaces in that pattern, just alternating commas and single spaces. Worth checking your output by eye for that doubled-comma artifact if your source text had blank lines between paragraphs and you picked the comma replacement.
Split and join does the work of a find-and-replace without building a dynamic regex
Rather than constructing a regular expression from the selected replacement value and running a global replace, the tool splits the text into an array on every detected line break and then rejoins that array using the replacement string as the glue between each piece. It's a simpler and safer approach for this specific case: there's no risk of regex special characters in the replacement value being misinterpreted, since Array.prototype.join() always treats its argument as a literal string, never as a pattern.
Why the three replacement choices exist
A single space is the right choice for turning a wrapped paragraph — text that was only broken across lines to fit a printed page or a narrow window, not because each line was a genuinely separate item — back into one flowing sentence, the same way word processors treat a soft line wrap. "Nothing" suits text where the line breaks were purely cosmetic artifacts of copying, like a PDF that inserted a break mid-word or mid-sentence for layout reasons, where inserting a space would incorrectly separate what should be one continuous word or number. The comma-and-space option is aimed at list-like input, turning a column of separate items — addresses, tags, or short entries pasted one per line — into a single comma-separated line suitable for pasting into a spreadsheet cell or a form field that expects one line of input.
Common situations where a single-line field forces this
Plenty of web forms, spreadsheet cells, and API fields only accept a single line of plain text and will silently truncate or reject anything with an embedded line break in it. A multi-line mailing address, a poem or quote pulled from a document, or a paragraph copied out of a PDF that reflows awkwardly when pasted are all common cases where you have genuinely multi-line source content that needs to become one line before it'll fit into whatever you're pasting it into next.
Frequently Asked Questions
Does this handle text with Windows-style or old Mac-style line breaks, not just Unix-style?
Yes. The tool detects CRLF (Windows), lone CR (old classic Mac), and lone LF (Unix/modern Mac and Linux) line endings in a single pass, so it correctly processes text regardless of what system or application it was originally created on.
Why does my output show a doubled comma like ", ," when I use the comma replacement?
The "collapse spaces" option only removes runs of two or more literal space characters, and a blank line joined with the comma replacement produces alternating commas and single spaces rather than a run of plain spaces, so that specific pattern isn't cleaned up by the collapse option. This happens when your original text had a blank line between paragraphs and you selected the comma replacement.
Can I remove line breaks and leave nothing in their place?
Yes, selecting "Nothing" from the replacement dropdown joins every piece of text directly together with no character inserted between them at all.
Is it safe to use a replacement value with special characters?
Yes. The tool joins text using Array.prototype.join(), which always treats the replacement as a literal string rather than as a regular expression pattern, so there's no risk of special regex characters being misinterpreted.
Is my text sent to a server when I use this tool?
No. All processing happens locally in your browser as you type; nothing is uploaded anywhere.