AltF Flow recipe
Clean up text copied from a PDF
Text copied from a PDF breaks at the end of every printed line and often splits words with hyphens. This recipe trims each line, straightens curly quotes, rejoins words hyphenated across a line break, joins single line breaks into spaces while keeping blank-line paragraph breaks, and collapses double spaces, giving you paragraphs you can paste into an editor.
- Free, no sign-up
- Runs in your browser
- Nothing uploaded
- Share recipes as a link
5 steps · runs in your browser · nothing uploaded
Pipeline
Remove leading and trailing spaces from each line.
9 → 9 linesReplace curly quotes, dashes and ellipses pasted from Word or Docs with plain ASCII.
9 → 9 linesFind: (\\p{L})-\\n(\\p{Ll}), Replace with: $1$2, Regular expression
9 → 7 lines (-2)Find: ([^\\n])\\n(?!\\n), Replace with: $1 , Regular expression
7 → 5 lines (-2)Turn runs of spaces and tabs into a single space.
5 → 5 lines
9lines57words343chars
5lines55words333chars-4 lines vs input
The 5 steps in this recipe
- 1
Trim every line
Remove leading and trailing spaces from each line.
- 2
Straighten smart quotes
Replace curly quotes, dashes and ellipses pasted from Word or Docs with plain ASCII.
- 3
Find and replace - Find: (\\p{L})-\\n(\\p{Ll}), Replace with: $1$2, Regular expression
Replace text everywhere. Supports regular expressions with $1 back-references.
- 4
Find and replace - Find: ([^\\n])\\n(?!\\n), Replace with: $1 , Regular expression
Replace text everywhere. Supports regular expressions with $1 back-references.
- 5
Collapse repeated spaces
Turn runs of spaces and tabs into a single space.
Change any option in the workspace above, switch a step off to compare, or add your own steps. Save it to reuse it, or share the recipe as a link.
Worked example
The committee reviewed the draft report and found that the proposed timeline was too ambitious for the available bud- get. Members asked for a revised plan by the next meeting. In the second session, the group discussed “open data” policies and agreed that sample datasets should be pub- lished under a permissive licence. Page 2 of 14
The committee reviewed the draft report and found that the proposed timeline was too ambitious for the available budget. Members asked for a revised plan by the next meeting. In the second session, the group discussed "open data" policies and agreed that sample datasets should be published under a permissive licence. Page 2 of 14
Why each step is there
- Trim every line first, so a line with only spaces counts as a real paragraph break.
- Straighten smart quotes turns curly quotes and dashes into plain ASCII.
- The first replace joins a letter, hyphen, line break and lowercase letter, so bud- / get becomes budget.
- The second replace turns a line break into a space unless the next line is blank, which keeps paragraphs separate.
- Collapse repeated spaces tidies the double spaces left by the PDF layout.
Things to check by hand
A real hyphenated compound split at a line end, such as well-known, will lose its hyphen. Page numbers, running headers and footnote markers are joined into the text like any other line; add Filter lines set to Remove with a pattern such as ^Page \d+ of \d+$ before the replace steps to drop them.
Clean text copied from a PDF: questions and answers
Why not just remove every line break?
That would merge all paragraphs into one block. Joining only single line breaks keeps the blank lines between paragraphs.
Does it work with scanned PDFs?
Only if the PDF already has selectable text. Scanned pages need OCR before you can copy anything.
What about columns and tables?
Multi-column PDFs often copy in the wrong order, and tables lose their structure. Those need manual fixing.
More recipes like this
Writers and editors
- Straighten smart quotes
- Find and replace
- Collapse repeated spaces
- Trim every line
- +1 more
- Strip HTML tags
- Encode or decode
- Trim every line
- Remove empty lines
- +1 more
- Trim every line
- Remove empty lines
- Find and replace
- Add prefix / suffix
- Trim every line
- Remove empty lines
- Encode or decode
- Apply a line template
- +1 more
- Trim every line
- Remove empty lines
- Find and replace
- Number lines
Every step you can add (41)
Clean up
- Trim whitespace
- Trim every line
- Remove empty lines
- Collapse repeated spaces
- Remove line breaks
- Strip HTML tags
- Straighten smart quotes
- Remove accents
- Remove punctuation
- Remove emoji
- Remove non-ASCII characters
Change case
- Change case
- Make URL slugs
Lines
- Sort lines
- Remove duplicate lines
- Keep only duplicated lines
- Compare with another list
- Count repeated lines
- Reverse line order
- Shuffle lines
- Keep a range of lines
- Truncate long lines
- Wrap at a width
- Split into lines
- Join lines
Find and filter
- Find and replace
- Filter lines
- Remove words or characters
Extract
- Extract
Data and formats
- Format JSON
- Minify JSON
- CSV to JSON
- JSON to CSV
- Lines to JSON array
- JSON array to lines
Encode and decode
- Encode or decode
Build output
- Add prefix / suffix
- Quote each line
- Number lines
- Apply a line template
- Add timestamp
AltF Flow runs entirely in your browser. Your text is never sent to AltFTool; saved recipes stay in this browser and shared links carry the steps only.