BLOG / GUIDE · 2026-04-21 · 7 min

How to remove line breaks from text (Excel, Word & more)

Five practical ways to strip line breaks from any text — Excel, Word, Notepad++, the terminal, or an instant browser tool. Decision table at the end.

The short answer. For a quick one-off, paste your text into the line break remover — two clicks. In Excel, press Ctrl+H and then Ctrl+J in the Find what box. In Word, the code is ^p. In Notepad++, switch the Replace dialog to Extended mode and search for \r\n. On the command line, tr -d '\n' wipes them all. The right choice depends on where the text already lives — the decision table at the bottom maps your situation to the fastest method.

What are line breaks, actually?

A "line break" is one of three invisible characters, and which one you have depends on where the text came from:

  • \n — line feed (LF). Unix, macOS, the web.
  • \r\n — carriage return + line feed (CRLF). Windows and most CSV exports.
  • \r — carriage return (CR) on its own. Vintage Mac OS up to System 9; almost never seen today.

A clean removal handles all three. A naive Find & Replace that only targets \n will leave stray \r characters in Windows-pasted text, which then show up as little squares in some editors. Worth knowing if you have ever wondered why a "removed" line break still looks broken.

How do you remove line breaks in Excel?

Excel stores an in-cell line break as CHAR(10) (line feed) when you press Alt+Enter. There are two reliable ways out.

Find & Replace, interactive.

  1. Select the cells you want to clean.
  2. Press Ctrl+H to open Find & Replace.
  3. Click into the Find what field, then press Ctrl+J. The field will look empty — that is correct; the line-break character is invisible.
  4. In Replace with, type a single space (recommended) or leave it blank.
  5. Click Replace All.

SUBSTITUTE formula, repeatable.

=SUBSTITUTE(A1, CHAR(10), " ")

Use this when you want the source column untouched. Replacing with a space prevents two words from merging — Smith\nJohn becomes Smith John, not SmithJohn. To also strip Windows-style carriage returns, nest the calls:

=SUBSTITUTE(SUBSTITUTE(A1, CHAR(13), ""), CHAR(10), " ")

The inner call removes the carriage return; the outer call handles the line feed. Text pasted from a Windows text file or another spreadsheet usually needs both.

What about Google Sheets?

Google Sheets gives you two clean options.

CLEAN() strips line breaks (and every other non-printable character) outright:

=TRIM(CLEAN(A1))

Wrapping it in TRIM also collapses any leading, trailing, or repeated spaces. Quick, but it removes the break entirely — words that were on separate lines will be glued together.

SUBSTITUTE() gives you control over the replacement:

=SUBSTITUTE(A1, CHAR(10), " ")

Same call as Excel. Replace with a space to keep word boundaries, or with ", " to turn a multi-line cell into a comma-separated list.

How do you remove line breaks in Microsoft Word?

Word distinguishes between two kinds of line break, which is why a Find & Replace sometimes seems to do nothing:

  • ^p — paragraph mark, what you get from Enter.
  • ^l — manual line break, what you get from Shift+Enter.

To remove paragraph marks:

  1. Press Ctrl+H.
  2. In Find what, type ^p.
  3. In Replace with, type a space, or leave it blank.
  4. Click Replace All.

For Shift-Enter breaks, do the same with ^l. To remove both at once, run the replace twice. A common gotcha: if Track Changes is on, Find & Replace ignores paragraph marks — turn it off first.

How do you remove line breaks in Notepad++ or VS Code?

Text editors are the most precise option, because they expose the actual line-ending characters and let you pick exactly what to target.

Notepad++

  1. Press Ctrl+H.
  2. Set Search Mode to Extended.
  3. In Find what: \r\n for a Windows file, \n for a Unix file. To cover both at once, switch to Regular expression mode and use \r?\n.
  4. Leave Replace with blank, or enter a space.
  5. Click Replace All.

VS Code

  1. Press Ctrl+H on Windows or Linux, Cmd+Opt+F on macOS.
  2. Click the .* icon in the search bar to enable regex.
  3. Search for \r?\n. The ? makes the carriage return optional, so the pattern catches both Windows and Unix breaks.
  4. Replace with a space, or leave it blank.

If the file is very large, use Find in Files rather than the in-file replace — the editor will stream the change instead of holding the whole document in memory.

How do you remove line breaks in the terminal?

On macOS or Linux, the one-line answer for a small file is:

tr -d '\n' < input.txt > output.txt

That deletes every newline. To also wipe carriage returns:

tr -d '\r\n' < input.txt > output.txt

For anything more nuanced — replacing breaks with a space rather than deleting them, collapsing runs of breaks, keeping paragraph spacing — reach for sed or awk:

# Replace every newline with a single space.
sed ':a;N;$!ba;s/\n/ /g' input.txt

The :a;N;$!ba; prelude reads the entire file into one buffer before the substitution. Without it, sed processes one line at a time and the replace appears to do nothing — the most common cause of "sed isn't working" complaints on Stack Overflow.

On Windows, the equivalent in PowerShell:

(Get-Content input.txt -Raw) -replace "`r?`n", " " | Set-Content output.txt

The backtick before r and n is PowerShell's escape character — the equivalent of a backslash in most other languages.

How do you do it online, without installing anything?

Open the line break remover. Paste the text. Pick what to replace the breaks with — a space (the default), nothing, or a custom string like | . Copy the result.

  • Nothing uploads. The tool is a few hundred bytes of JavaScript that runs in your browser. Open DevTools → Network and run a transformation — you will see zero outbound requests carrying your text.
  • Paragraph-aware. Toggle Keep paragraphs to preserve double-newline breaks while collapsing single ones. Useful for reflowing text that wrapped at column 80 in a PDF.
  • Handles CRLF, LF, and CR. Every variant gets normalised before the replace, so Windows-pasted text does not leave invisible \r stragglers behind.

Browser memory is the only ceiling, because nothing leaves the tab — even very large pastes run in-tab without an upload step.

Which method should you use?

Where the text already isFastest method
An Excel sheetFind & Replace with Ctrl+J, or SUBSTITUTE
A Google Sheet=TRIM(CLEAN(A1)) or SUBSTITUTE
A Word document with mixed break typesFind & Replace with ^p and ^l
Open in Notepad++ or VS CodeRegex search for \r?\n
Pasted from a PDF or email, one-offBrowser tool
A 1 GB log file, or scripted batchtr, sed, or PowerShell
Sensitive (legal, medical, internal)Browser tool or terminal — never an upload-based site

The choice usually comes down to where the text already lives. If it is in a spreadsheet, stay in the spreadsheet. If it is a one-off paste from somewhere, the browser tool is faster than opening a desktop app. If it is huge, the terminal is the only thing that scales.

Frequently asked questions

Why doesn't my Find & Replace catch every line break?

Usually because the text contains \r\n (Windows) but your replace only targets \n, or vice versa. Match both: use \r?\n in regex-aware tools, or chain two SUBSTITUTE calls in Excel. The browser tool normalises all three variants up front, so it always catches them.

What is the difference between a "soft" and a "hard" line break?

"Hard" usually means a paragraph break — pressing Enter — that starts a new paragraph. "Soft" means a manual line break inside a paragraph, from Shift+Enter. Same paragraph, just wrapped. Word represents them as ^p and ^l respectively. Plain-text editors do not distinguish; everything is just \n.

Will removing line breaks merge two words into one?

Yes, if you replace the break with nothing. To avoid it, replace with a single space — that turns Smith\nJohn into Smith John. Both the browser tool and Excel's SUBSTITUTE(..., " ") default to the safer space.

How do I keep paragraph breaks but remove the wrap-at-80 line breaks?

Use a tool that distinguishes single newlines from double newlines. In the browser tool that is the Keep paragraphs toggle: single breaks collapse to a space, double breaks (blank lines between paragraphs) stay intact. In sed it is doable but fiddly — you have to read the file into one buffer, replace single \n with a space, and leave \n\n alone.

Is it safe to paste sensitive text into an online line-break remover?

Only if the tool runs entirely in the browser. Open DevTools, switch to the Network tab, paste your text, and run the transformation. If you see an outbound request carrying your data, the page sent it to a server. The joinlines tool makes zero requests after the page loads — verifiable in DevTools, every time.

What's the fastest way for a 1 GB log file?

Terminal, no contest. tr -d '\n' < big.log > cleaned.log streams bytes straight from disk and finishes quickly. Excel and Word will refuse to open the file. Browser tools can load large files in principle, but at that size the clipboard paste step itself becomes the bottleneck before the tool does. Streaming via tr or sed is the only option that scales linearly with file size.

— the joinlines team, 2026-04-21

§ — PRIVACY Your text never leaves your browser. No upload, no account, no logs on what you paste.
PRIVACY PAGE ↗