What Are Line Breaks?
A line break is an invisible character that tells a computer to start a new line. When you press Enter on your keyboard, you insert a line break character. Despite being invisible, line breaks are actual characters stored in the file — and different operating systems use different line break characters, which is the root cause of most line break problems.
Remove unwanted line breaks from any text with WritePadPro's Remove Line Breaks tool — paste text with broken lines and get clean, flowing paragraphs in one click.
CR, LF, and CRLF: The Three Line Break Types
| Type | Characters | Hex Code | Used By |
|---|---|---|---|
| LF (Line Feed) | \n | 0x0A | Linux, macOS, Unix, modern web |
| CR (Carriage Return) | \r | 0x0D | Classic Mac OS (pre-2001) |
| CRLF | \r\n | 0x0D 0x0A | Windows, HTTP protocols, email (SMTP) |
Why Three Different Types Exist
The terminology comes from mechanical typewriters. "Carriage Return" moved the print head back to the left margin. "Line Feed" advanced the paper up one line. Typewriters needed both actions. When computers adopted text, different manufacturers chose differently: Unix chose LF alone (efficient — one character), Windows chose CRLF (faithful to the typewriter model), and early Mac chose CR alone (simplified).
This historical accident still causes problems today. A file created on Windows and opened on Linux may show stray ^M symbols at the ends of lines, and shell scripts saved with CRLF endings can fail to run. A file created on Linux and opened in Windows Notepad may display as one continuous line (Notepad historically required CRLF, not just LF — though modern Notepad handles both).
Why Unwanted Line Breaks Appear
Copying From PDFs
PDFs store text as positioned characters, not flowing paragraphs. When you copy text from a PDF, the extraction software inserts a line break at the end of every visual line — even when the original text was a continuous paragraph. A 10-line paragraph in a PDF becomes 10 separate lines in your clipboard, breaking mid-sentence at whatever point the PDF column width dictated.
Email Plain Text Wrapping
Email clients often insert "hard wraps" at 72 or 76 characters per line in plain text emails. This was necessary for old terminal displays that could not handle long lines. When you copy text from such an email, every line ends with a forced break at the wrap point, producing choppy text that needs to be rejoined into flowing paragraphs.
OCR Output
Optical Character Recognition software preserves the visual line structure of the scanned document, inserting line breaks where each printed line ends. A scanned page of a book produces text with breaks at the end of every line — breaks that were determined by the book's page width, not by paragraph structure.
Cross-Platform File Transfers
Files transferred between Windows, macOS, and Linux may accumulate mixed line break types. A file edited on multiple platforms might contain LF in some places and CRLF in others, producing inconsistent line spacing when opened. For related spacing cleanup, see our Remove Extra Spaces Guide.
Web Scraping and Data Extraction
Text extracted from HTML often contains line breaks from the source code structure. An HTML paragraph with inner line breaks in the source code produces text with breaks that do not correspond to actual paragraph boundaries. The Remove Empty Lines tool handles the related problem of excessive blank lines between paragraphs.
Removing All Line Breaks vs Converting to Spaces
There are two approaches to handling unwanted line breaks, and choosing the wrong one produces different problems.
Remove All (Replace With Nothing)
Deletes every line break character entirely. The last word of one line joins directly to the first word of the next line with no separator.
Before:
The quick brown
fox jumps over
the lazy dog
After (breaks removed):
The quick brownfox jumps overthe lazy dog
This creates merged words — "brownfox" and "overthe" — which is almost never what you want.
Replace With Spaces (The Correct Approach)
Replaces every line break with a single space, maintaining word separation.
After (breaks replaced with spaces):
The quick brown fox jumps over the lazy dog
This produces clean, flowing text. WritePadPro's Remove Line Breaks tool uses this approach: it trims spaces at the start and end of each line and joins the lines with a single space. An optional setting also rejoins words split by a hyphen at a line end (exam-/ple → example).
The Double Space Trap
When lines end with a space before the break, replacing the break with a space creates a double space. The sentence "The quick brown " (trailing space) + line break + "fox" becomes "The quick brown fox" (double space). Simple find-and-replace methods need a follow-up pass with Remove Extra Spaces. WritePadPro’s tool trims each line before joining, so the joins never create double spaces, though double spaces inside a line stay until you clean them.
Preserving Paragraph Breaks While Removing Line Breaks
The most common real-world scenario is: you want to remove line breaks within paragraphs (joining broken lines) while keeping the breaks between paragraphs (preserving paragraph structure).
The Pattern
Paragraph breaks are typically represented as double line breaks (two consecutive newlines: \n\n or a blank line between paragraphs). Line wrapping breaks are single line breaks (one newline: \n within a paragraph).
The Strategy
- First: Temporarily replace double line breaks (paragraph breaks) with a unique placeholder — like "PARA_BREAK"
- Second: Replace all remaining single line breaks with spaces (these are the wrapping breaks)
- Third: Restore the paragraph breaks by replacing the placeholder back to double line breaks
This preserves your paragraph structure while joining the broken lines within each paragraph. The result is clean, flowing text with proper paragraph separation.
In Code
// JavaScript
let text = input
.replace(/\n\n/g, "PARA_BREAK")
.replace(/\n/g, " ")
.replace(/PARA_BREAK/g, "\n\n")
.replace(/ +/g, " ");WritePadPro’s tool does this by default: its Keep paragraph breaks (blank lines) mode joins wrapped lines and keeps one blank line between paragraphs, and Smart mode keeps list items (-, *, •, 1.) on their own lines. Choose Remove all line breaks only when you want one continuous line. For related cleanup, see our Remove Empty Lines Guide which handles the complementary problem of too many blank lines between paragraphs.
Line Breaks in Different Contexts
HTML
In HTML, line breaks in source code are ignored — the browser treats all whitespace (spaces, tabs, newlines) as a single space unless you use specific elements. To force a line break in HTML, use the <br> tag. To preserve line breaks as typed, use the <pre> element or CSS white-space: pre-line.
Markdown
In Markdown, a single line break is ignored (the text continues on the same line). To force a line break, add two spaces at the end of a line or use a backslash (\) before the newline. A blank line creates a new paragraph.
CSV Files
Line breaks inside CSV field values must be enclosed in double quotes. The CSV line:"John Smith","123 Main St\nApt 4","New York"
contains a line break in the address field. Removing line breaks from CSV data without respecting quoted fields corrupts multi-line field values.
JSON
JSON strings cannot contain literal line breaks. Newlines must be escaped as \n. A JSON file with unescaped line breaks inside string values is invalid and will fail parsing. For related cleanup, see our Remove Duplicate Lines Guide.
Programming
Different languages represent line breaks differently in string literals: \n (most languages), Environment.NewLine (C#), os.linesep (Python), PHP_EOL (PHP). When a file needs the platform’s native line ending, use these constants rather than hardcoding \r\n.
Detecting Line Break Types
Before cleaning line breaks, it helps to know which type your text contains.
In a Text Editor
Many code editors show the line break type in the status bar: "LF" (Unix/Mac), "CRLF" (Windows), or "CR" (old Mac). VS Code and Notepad++ display it by default, and in VS Code you can click the indicator to convert between types.
In a Hex Editor
Open the file in a hex editor and look for: 0A (LF), 0D (CR), or 0D 0A (CRLF). Hex editors show the raw bytes, making line break types unambiguous.
With Command Line
# Linux/Mac: show line ending type
file myfile.txt
# Output: "ASCII text, with CRLF line terminators"
# Count lines that end in CRLF
grep -c $'\r$' myfile.txt
# Count every CR character in the file
tr -cd '\r' < myfile.txt | wc -cUsing WritePadPro's Remove Line Breaks Tool
WritePadPro's Remove Line Breaks tool cleans up broken text in seconds.
Step 1: Paste Your Text
Open the Remove Line Breaks tool and paste your broken text — from PDFs, emails, OCR output, or any source with unwanted line breaks.
Step 2: Choose a Mode and Remove Breaks
Pick a Mode: Keep paragraph breaks (blank lines), the default, or Remove all line breaks. Leave Smart mode on to keep list items on their own lines, and tick the hyphen option to rejoin words split across lines. Click Remove Breaks. The tool handles LF, CR and CRLF endings and joins lines with a single space.
Step 3: Review the Result
A live panel shows Line Breaks, Paragraphs, how many breaks Will Be Removed and Words. After you click the button, the joined text replaces your input and a summary reports how many line breaks were removed. In the default mode your paragraphs stay separate.
Step 4: Copy or Download
Use Copy Result or Download .txt to take the text to your document, email, or publishing platform. Undo restores the original.
Privacy
All processing runs locally in your browser. Your text is never transmitted to any server.
Summary
Line breaks are invisible characters that start new lines. Three types exist (LF, CR, CRLF) due to historical differences between Unix, Mac, and Windows. Unwanted line breaks appear from PDF copy-paste, email wrapping, OCR, cross-platform transfers, and web scraping.
The correct removal approach replaces breaks with spaces (not nothing) to preserve word separation. For text with paragraph structure, keep the paragraph breaks while removing the wrapping breaks — WritePadPro’s default mode does this, and in code the placeholder technique does the same.
Clean up broken text with WritePadPro's Remove Line Breaks tool — instant line joining that keeps paragraph breaks by default, running entirely in your browser.