Extract Emails from Text (Regex + Free Online Tool)
You have a wall of text—maybe a document, a webpage, or log files—and you need to extract all the email addresses from it.
Manually finding them? Tedious and error-prone.
This guide shows you the fastest way to extract emails from any text, plus the regex patterns behind it.
Quick Solution: Extract Emails Online
The fastest way to extract emails:
- Go to CleanTextLab's Email Extractor
- Paste your text
- Get all email addresses instantly
- Export as TXT, CSV, or copy to clipboard
No signup. No ads. Works offline.
Example: Extracting Emails
Input text:
Contact us at support@example.com for help.
Sales inquiries: sales@company.org
John's email is john.doe@email.co.uk
Send feedback to feedback+test@gmail.com
Extracted emails:
support@example.com
sales@company.org
john.doe@email.co.uk
feedback+test@gmail.com
The Email Extractor finds all valid emails, including:
- Subdomains (email@sub.domain.com)
- Plus addressing (email+tag@gmail.com)
- Country TLDs (.co.uk, .com.au)
- Dots and hyphens in local parts
The Regex Behind Email Extraction
Basic Email Regex
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
Breakdown:
[a-zA-Z0-9._%+-]+– Local part (before @)@– The @ symbol[a-zA-Z0-9.-]+– Domain name\.– Literal dot[a-zA-Z]{2,}– TLD (com, org, co.uk)
More Robust Regex (RFC 5322 Compliant)
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
Pro tip: Don't write this yourself. Use the Email Extractor tool which handles edge cases correctly.
Extract Emails in Code
JavaScript
const text = "Contact support@example.com or sales@company.org";
const emailRegex = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
const emails = text.match(emailRegex);
console.log(emails);
// ['support@example.com', 'sales@company.org']
Python
import re
text = "Contact support@example.com or sales@company.org"
pattern = r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}'
emails = re.findall(pattern, text)
print(emails)
# ['support@example.com', 'sales@company.org']
PHP
$text = "Contact support@example.com or sales@company.org";
preg_match_all('/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/', $text, $matches);
print_r($matches[0]);
// ['support@example.com', 'sales@company.org']
Bash (grep)
grep -oE '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' file.txt
Common Use Cases
1. Building Contact Lists
Extract emails from:
- Business directories
- LinkedIn exports
- Conference attendee lists
- Email threads
2. Data Cleaning
Clean messy CRM data:
- Extract valid emails from notes fields
- Find emails in unstructured text
- Validate email formats
3. Log Analysis
Find emails in:
- Server logs
- Application logs
- Error reports
4. Web Scraping
Extract emails from:
- Scraped web pages
- PDF documents
- Exported data
5. Document Processing
Extract from:
- Word documents
- PDF files (copy text first)
- Spreadsheets
Features of the Email Extractor Tool
Automatic Deduplication
Extracts unique emails only. No duplicates.
Domain Filtering
Filter emails by domain:
- Only @gmail.com addresses
- Exclude certain domains
- Group by domain
Export Options
- CSV – Open in Excel/Sheets
- TXT – Plain text list
- JSON – For programmatic use
- Excel – Direct download
Validation
Each extracted email is validated for proper format.
Edge Cases Handled
The Email Extractor correctly handles:
| Email Type | Example | Status |
|---|---|---|
| Standard | user@example.com | ✅ Extracted |
| Subdomain | user@mail.example.com | ✅ Extracted |
| Plus addressing | user+tag@gmail.com | ✅ Extracted |
| Country TLD | user@example.co.uk | ✅ Extracted |
| Numbers | user123@example.com | ✅ Extracted |
| Dots in local | first.last@example.com | ✅ Extracted |
| Hyphens | user-name@example.com | ✅ Extracted |
What's NOT a Valid Email?
These are rejected:
| Invalid Format | Reason |
|---|---|
| user@example | Missing TLD |
| @example.com | Missing local part |
| user @example.com | Space in address |
| user..name@example.com | Double dots |
| .user@example.com | Starts with dot |
Privacy & Security
Your Data is Private
All processing happens in your browser. The text you paste:
- Never leaves your device
- Is not stored anywhere
- Is not sent to any server
Ethical Use
Please use extracted emails responsibly:
- ✅ Your own contact lists
- ✅ Data cleaning tasks
- ✅ Research with consent
- ❌ Spam or unsolicited emails
- ❌ Selling email lists
Frequently Asked Questions
How many emails can it extract?
No limit. The tool handles thousands of emails efficiently.
Does it validate emails?
Yes, format validation is included. It won't extract invalid patterns.
Can it extract from PDFs?
Copy text from the PDF first, then paste into the tool.
Can I filter by domain?
Yes, you can filter results to show only specific domains.
Is it free?
Completely free. No signup required.
Alternative Methods
Using grep (Command Line)
grep -oE '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' file.txt | sort -u
Pro: Works offline. Con: Regex can miss edge cases.
Using Excel
Not recommended. Excel doesn't have built-in email extraction.
Using Python Script
Good for automation but requires coding knowledge.
Using CleanTextLab (Recommended)
- No installation
- Handles all edge cases
- Export to any format
- Try it free
Related Tools
- Remove Duplicates – Deduplicate email lists
- Regex Tester – Test your own patterns
- URL Extractor – Extract URLs from text
Conclusion
Extracting emails from text is a common task that shouldn't require coding. With CleanTextLab's Email Extractor:
- Paste any text
- Get all emails instantly extracted
- Export as CSV, TXT, or JSON
- No duplicates, properly validated
No signup. No ads. Works offline.
Try it now: cleantextlab.com/tools/email-extractor
Try the tools mentioned
Fast, deterministic processing as discussed in this post.