Remove Line Breaks
Paste text with unwanted line breaks, from a PDF, an email or a terminal, and get clean paragraphs back. Paragraph breaks, hyphenated words and Markdown lists, tables and code blocks are handled for you.
Which mode to use
| You have | Use | What happens |
|---|---|---|
| Text copied from a PDF or an ebook | Keep paragraphs, hyphens on | Lines inside a paragraph are joined; blank lines stay; "exam- ple" becomes "example" |
| A plain text email wrapped at 72 or 78 characters | Keep paragraphs | Each paragraph becomes one line, so it reflows in any window |
| A column of values (one per line) you want as a list | Remove every line break, custom text , | apple, pear, plum |
| A hard-wrapped Markdown file or README | Keep paragraphs, Markdown aware on | Paragraphs and list items are unwrapped; headings, tables and code blocks are left as they are |
| Long lines you need to fit a width (a commit message, a plain text email) | Rewrap at a width | Paragraphs are joined first, then broken again at spaces before the width |
Why PDFs give you broken lines
A PDF does not store paragraphs. It stores lines of text placed at positions on a page, so when you copy, the viewer has to guess where paragraphs start and usually puts a line break at the end of every visual line. Justified text adds hyphens where a word was split. Keep paragraphs mode joins those lines and only keeps breaks where there was a blank line. If your copy has no blank lines between paragraphs, everything becomes one paragraph; add a blank line where each paragraph should start and run it again. To turn a whole PDF into structured text with headings and lists, try PDF to Markdown.
Line breaks in Markdown
In Markdown, a single line break inside a paragraph is normally treated as a space, so a hard-wrapped file still renders as normal paragraphs. Some renderers do keep single line breaks (GitHub does in issue and pull request comments, and this site's blog does), which is when wrapped text suddenly looks like a narrow column. Unwrapping the paragraphs fixes it everywhere. The Markdown aware option keeps the lines that must stay separate:
| Line starts with | Kept on its own line because |
|---|---|
# to ###### | Heading |
- * + 1. 1) | List item (a wrapped line after it is joined to the item) |
> | Block quote |
| | Table row (rows are never joined) |
``` or ~~~ | Code block (everything inside is left exactly as is) |
---, ***, [^1]:, an HTML tag | Horizontal rule, footnote definition, HTML block |
To force a line break inside a paragraph in Markdown, end the line with two spaces or a backslash, or use <br>. The Markdown line break guide covers which apps support which.
Removing line breaks in code and spreadsheets
| Where | Remove all | Keep paragraphs |
|---|---|---|
| JavaScript | s.replace(/\r?\n/g, ' ') | s.replace(/([^\n])\r?\n(?!\r?\n)/g, '$1 ') |
| Python | ' '.join(s.split()) (also collapses spaces) | re.sub(r'(?<!\n)\n(?!\n)', ' ', s) |
| Excel / Google Sheets | =SUBSTITUTE(A1, CHAR(10), " ") | No simple formula |
| Shell | tr '\n' ' ' < file.txt | fmt -w 10000 file.txt |
Questions
Is my text uploaded?
No. Everything runs in your browser and nothing is sent anywhere.
Why are some hyphens kept?
A hyphen at the end of a line is only removed when the next line starts with a lowercase letter, so "exam-" + "ple" joins but "COVID-" + "19" or "self-" + "Driving" does not. Real compound words split at their hyphen ("well-" + "known") will lose the hyphen, so turn the option off for text full of those.
What counts as a line break?
Windows (CRLF), Unix (LF) and old Mac (CR) line endings are all handled. The result uses LF.
Related tools
- Sentence Case Converter: fix text typed in caps lock, or convert to Title Case.
- Hidden character finder: find non-breaking spaces, zero width spaces and other characters you cannot see.
- PDF to Markdown: turn a PDF into Markdown with headings and lists.
- Markdown to Plain Text: strip Markdown symbols.
- Markdown List Formatter: clean up bullets and numbering in lists.