Remove line breaks and extra spaces from text copied out of a PDF
Paste text full of hard returns, pick a mode, and copy the result. You can merge everything into one paragraph with spaces, merge without spaces (for Chinese), remove blank lines only, trim each line, or just collapse repeated spaces. Processing happens in your browser; the text is never uploaded.
Open the tool:Remove Line Breaks
When line-break cleanup is the job
Copy body text out of a PDF, a WeChat article or certain web pages and every line ends with a hard return. Paste that into Word, an email or a CMS and the paragraph fragments; change the window width and you get odd short lines.
The second problem is whitespace: text copied from the web often carries repeated spaces, trailing spaces and full-width spaces. It looks loose, and pasting it into Markdown or code drags invisible characters along.
- Turning PDF body text back into continuous paragraphs
- Removing repeated, trailing and full-width spaces from web copy
- Merging subtitle or lyric lines into paragraphs
- Tidying fragments copied out of chat logs or emails
Pick the right mode first
Chinese and English need different merge modes. Merge without spaces joins lines directly, which is right for Chinese. Merge into a paragraph trims each line and joins with a single space, which is right for English — use the other mode and English words run together, or Chinese gains spaces it should not have.
If the text contains lists, tables or code, do not merge. Merging flattens indentation and line structure along with the line breaks. Use remove blank lines instead: it collapses runs of blank lines into one newline and leaves the body intact. For conservative cleanup, collapse extra spaces, which does not trim each line and preserves leading indentation while fixing trailing spaces and repeated spaces, including full-width ones.
- Chinese body text: merge without spaces
- English body text: merge with spaces
- Lists or code: remove blank lines only
- Whitespace only, keep indentation: collapse extra spaces
- Trimming every line also removes code indentation — treat it as destructive
It is irreversible, and there are alternatives
Merging cannot be undone on the page. Paragraph information disappears the moment the line breaks are replaced, so if you realise you needed the structure, you have to paste the original again. Keep a copy, or make sure the source file still exists.
If you still need per-line work — sorting, deduplication, find and replace — do that first and merge afterwards. For structured cleanup, such as merging only Chinese lines while keeping English paragraphs, or re-breaking at punctuation, a script or regex is the better tool. When converting a whole PDF, prefer an extractor that preserves paragraphs.
- Back up the original before merging
- Per-line operations belong before the merge, not after
- Structured cleanup: a script or regex
- PDF extraction: prefer a tool that reconstructs paragraphs
FAQ
Why does text copied from a PDF break at every line?
PDF stores text as positioned glyphs, not as paragraphs. Readers reproduce what they see, so copying usually emits one visual line at a time with a hard return at the end. OCR output from scans is worse, often one line per detected row. Recovering paragraphs means merging those returns or using a converter that reconstructs them.
Why does Chinese text gain spaces after merging?
Merge into a paragraph trims each line and joins them with a single space, so Chinese characters end up separated by spaces. Use merge without spaces for Chinese and the spaced mode for English; the wrong choice either adds gaps in Chinese or fuses English words together.
The paragraphs are gone — can I get them back?
Not on the page. Pasting the original text again is the only reliable recovery. To keep paragraphs, use remove blank lines from the start: it collapses blank runs into a single newline without merging the body. Also finish sorting, deduplication and find-and-replace before merging, because once the newlines are gone you cannot reconstruct them.
Related tool:Remove Line Breaks