Skip to content
Screenshot2Text

Guide

How to remove line breaks from PDF or OCR text

Text copied from a PDF or read from an image keeps a break at every visual line. Join lines puts the paragraphs back together and keeps blank lines and lists.

Updated September 25, 2026

The quick answer

Paste the text into the result box on the Screenshot2Text home page or any image or PDF to text page, then press Join lines. Lines inside each paragraph become one line, while blank lines and bullet or numbered list lines stay. Press Undo join to get the original back.

This works the same for text you copied out of a PDF and for text the site read from a screenshot or a scanned page. The rest of this guide shows a real before and after for both, other ways to do it, and when to keep the breaks.

Why text copied from a PDF has line breaks

Most PDFs do not store paragraphs. They store short runs of text, each placed at an exact spot on the page. When you copy, the viewer rebuilds the text from those runs and ends each visual line with a break, so a paragraph pastes as a stack of short lines.

The blank line between paragraphs is often lost too. On the page it is only extra space, not a character, so many copies run the last line of one paragraph straight into the first line of the next.

We tested this with a small PDF that has a real text layer: two short paragraphs in a narrow column. We pulled its text out with two common PDF text engines, pdftotext from Poppler and pdf.js, the engine behind the Firefox PDF viewer. Both gave exactly the same six lines, with no blank line between the paragraphs:

Text copied from the test PDF, one row per line
LineText
1Most PDFs do not store paragraphs. They store short
2runs of text, each placed at an exact spot on the page,
3so a reader can draw every line where it belongs.
4When you copy from a PDF, the viewer rebuilds the
5text from those runs and adds a break at the end of
6each visual line.

Paste and join a PDF copy

We pasted those six lines into the result box on PDF to text and pressed Join lines. The lines became one paragraph. Because the copy had lost the blank line, the two paragraphs ran together too.

The fix is one extra keystroke. Press Undo join, click at the end of the line where a paragraph ends, press Enter to add a blank line, then press Join lines again. That gave back both paragraphs as written:

Join lines on the pasted PDF text
VersionResult
Joined right after pastingMost PDFs do not store paragraphs. They store short runs of text, each placed at an exact spot on the page, so a reader can draw every line where it belongs. When you copy from a PDF, the viewer rebuilds the text from those runs and adds a break at the end of each visual line.
Blank line added, then joined: paragraph 1Most PDFs do not store paragraphs. They store short runs of text, each placed at an exact spot on the page, so a reader can draw every line where it belongs.
Blank line added, then joined: paragraph 2When you copy from a PDF, the viewer rebuilds the text from those runs and adds a break at the end of each visual line.

If nothing copies from the PDF

If you cannot select any text, the PDF is probably a scan with no text layer. Drop it on PDF to text to read each page with OCR, then press Join lines on the result. Why you cannot copy text from a PDF helps you tell a scan from a PDF that blocks copying.

Why OCR text has line breaks

OCR reads an image one line of type at a time. When a line ends in the picture, the text gets a line break. The reader cannot tell a line that ended with the sentence from a line that ended because the app ran out of width, so it keeps every break.

Screenshot2Text keeps those breaks on purpose. Addresses, lists, code, and table rows need them, and removing them by guesswork would damage those. The result box shows the text in the same shape as the image, and you decide whether to join it.

Narrow sources make it worse. A phone screenshot, a sidebar, or a two column page can wrap every few words, so a pasted paragraph turns into a tall stack of short lines.

A real screenshot example

We made a screenshot of two short paragraphs in a narrow column, with one word split by a hyphen at the end of a line. We ran it through Screenshot2Text in Chromium, using a local build of this site.

Every word came back correctly. The text also kept all 8 line breaks inside the two paragraphs, plus the blank line between them. This is exactly what landed in the result box:

Raw OCR output from the screenshot, one row per line
LineText
1When you copy text out of a screenshot,
2every line of the picture ends with a line
3break. The OCR reader has no way to
4know that the app simply ran out of
5width, so the text keeps the same nar-
6row shape as the image.
7(blank line)
8Joining the lines puts each paragraph
9back together, so you can paste it into
10an email or a document without fixing
11every line by hand.

The screenshot text after Join lines

After one press of Join lines, the box held two paragraphs. The split word "nar-" and "row" became "narrow", because the next line started with a lowercase letter. The blank line between the paragraphs stayed, since OCR saw the gap in the image. The word count under the box went from 71 to 70, because the two halves became one word.

The screenshot text after Join lines
ParagraphText
1When you copy text out of a screenshot, every line of the picture ends with a line break. The OCR reader has no way to know that the app simply ran out of width, so the text keeps the same narrow shape as the image.
2Joining the lines puts each paragraph back together, so you can paste it into an email or a document without fixing every line by hand.

How Join lines works

Press Join lines next to Copy text and Download .txt. It works on whatever is in the result box: text the site read from your file, text you pasted, or text you edited.

A line break inside a paragraph becomes a space. A word split with a hyphen at the end of a line is rejoined when the next line starts with a lowercase letter, so "exam-" and "ple" become "example". If the next line starts with a capital letter or a number, the hyphen stays, so a name like Jean-Paul keeps its hyphen.

Blank lines stay, because they mark real paragraph breaks. Lines that start with a bullet or a number, such as "- item", "• item", "1. step", or "2) step", stay on their own lines. A list item that wraps onto a second line is joined into one line. With several files, the file name headers stay on their own lines too.

To go back, press Undo join. The button switches to Undo join after a join and puts the text back exactly as it was. Undo is cleared once you type in the box, so undo before you edit if you want the original back.

Other ways to remove line breaks

Microsoft Word: paste the text, then open Replace (Ctrl+H on Windows, or Edit, Find, Replace on a Mac). In the Find box, ^p stands for a paragraph mark. To keep real paragraphs, use three passes. Replace ^p^p with a marker that is not in the text, such as ###. Replace ^p with a single space. Then replace ### with ^p. If ^p finds nothing, the breaks may be manual line breaks, so try ^l instead. This does not fix words split with a hyphen.

Regular expressions: in an editor with regex search, such as VS Code, turn on regex in Find and Replace. First find ([a-z])-\n([a-z]) and replace it with $1$2 to rejoin split words. Then find (?<!\n)\n(?!\n) and replace it with a single space. That joins lines inside paragraphs and leaves blank lines alone. On our screenshot example it gave the same result as Join lines. It does not protect list lines, so check lists afterward.

Plain text editor: pasting into Notepad, or TextEdit in plain text mode, removes formatting but keeps every line break. It is a clean place to run the regex above, not a fix by itself. Some editors have a join command. In VS Code, select the lines and run Join Lines from the Command Palette. In Notepad++, select the lines and choose Edit, Line Operations, Join Lines. Both join every selected line, so select one paragraph at a time.

When not to join lines

Tables: each row is its own line, and joining turns the table into one long run of cells. Keep table text as it came out. Table text from a screenshot covers tables.

Lists without bullets: Join lines keeps lines that start with a bullet or a number, but a plain list, like a shopping list or a menu, looks like a wrapped paragraph and will be joined. Press Undo join, or copy the list before you join the rest.

Code and terminal output: line breaks carry meaning in code. Keep it exactly as it came out. OCR code from tutorial screenshots has tips for code.

Addresses, poems, lyrics, and form fields: the breaks are part of the content, so leave them.

When you are not sure, join, read the result, and press Undo join if it looks wrong.