Email validation regex is one of the most misused patterns in web development: too strict and you reject legitimate addresses, too loose and you accept garbage.
Loading Regex Tester…
Test email regex against edge-case addresses instantly
See which parts of an address your pattern captures
Understand the tradeoffs between strict and lenient patterns
Copy a tested pattern directly into your validation code
Drop the Regex Tester into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/developer/regex-tester?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="Regex Tester by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
Email address validation is a classic case where perfect is the enemy of good. The full RFC 5321 specification permits addresses that no real user would ever have: local parts with spaces inside quoted strings, comments in parentheses before and after the at sign, IP address domain literals enclosed in square brackets, and international characters in the domain using punycode encoding. Writing a regex that accepts every syntactically valid RFC address while rejecting all invalid strings is extremely complex and produces a pattern that is both difficult to maintain and so permissive it provides little practical filtering benefit. Most production systems deliberately use a simplified pattern that covers the 99.9% of real addresses that conform to common conventions, then rely on a confirmation email to verify deliverability, which is the only true end-to-end validation.
A practical email regex typically has three components: the local part before the at sign, the at sign separator itself, and the domain after it. The local part character class matches word characters and common punctuation including dots, hyphens, underscores, and plus signs. The domain segment matches one or more DNS-style labels separated by dots, where each label consists of word characters and hyphens. The top-level domain is constrained to two or more letters to cover both two-character country codes and longer generic TLDs. A common working pattern is ^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$. This accepts user@example.com and user+tag@sub.domain.co.uk while rejecting strings missing the at sign or a dot-separated domain.
For real-world deployment, the key design decisions are: whether to allow plus-sign subaddressing in the local part, whether to permit consecutive dots in the local part which the RFC disallows but some implementations accept, and how to handle new generic TLDs with long suffixes like .photography or .technology that existing patterns with {2,4} TLD bounds incorrectly reject. Test your final pattern against a diverse set that includes disposable address services, corporate subdomain addresses, plus-addressed Gmail and Fastmail addresses, and deliberately invalid strings before deploying to production.
Email patterns are a frequent source of ReDoS vulnerabilities because writers naturally reach for nested quantifiers when handling multi-label domains. The pattern ^([a-zA-Z0-9]+\.)+[a-zA-Z]+$ looks innocent but contains a classic backtracking trap: a long input ending with one disallowed character forces the engine to explore an exponential number of ways to assign the dot-separated labels before declaring failure. The fix is to use an unrolled-loop pattern such as ^[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*$ which has no overlap between the initial segment and the alternative. Always benchmark email patterns against pathological inputs (long strings ending in a single disallowed character) before deploying them on any path that accepts untrusted user input, especially in serverless environments where a hung function costs real money per second.
Paste your email validation regex into the pattern field, then paste a list of email addresses (one per line) into the test string to see which ones match and which do not.
Step-by-step guide to regex for email validation, test patterns against real addresses:
Open the Regex Tester
Navigate to the FixTools Regex Tester. The tool opens in your browser immediately without any setup. The pattern field, flag selector, and test string area are all available on a single screen.
Enter your email regex
Paste your email validation pattern into the pattern field. If you need a starting point, use ^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$. This covers the vast majority of real-world addresses including plus-sign subaddressing and multi-label domains.
Enable the g and m flags
Enable the global flag to find all matches in the test string and the multiline flag so that each line in the test area is evaluated against the anchored pattern independently. Together these flags let you test a full list of addresses in a single paste operation.
Paste test addresses
Enter a list of email addresses one per line. Include addresses that cover common edge cases: plus-sign subaddresses, subdomain addresses like user@mail.company.co.uk, long TLDs like user@studio.photography, and intentionally invalid strings like "notanemail", "@nodomain.com", and "missing-at-sign.com".
Common situations where this approach makes a real difference:
Validating a registration form email field
A frontend developer tests the pattern ^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$ against a list of 20 test addresses. The tester confirms it highlights user@example.com, first.last@company.org, and user+tag@mail.co.uk correctly, while producing no match for "notanemail", "missing@tld", and "@nodomain.com". The developer copies the confirmed pattern directly into the form library validator and adds a confirmation email step as a second-stage deliverability check after the regex pre-screen.
Filtering email addresses from a CSV export
A data engineer needs to extract valid email addresses from a CSV column that also contains phone numbers and free text in inconsistent formats. The email regex with the g flag and String.matchAll() in Node.js selectively pulls address-shaped strings from each cell. Testing a sample of 50 raw CSV rows in the browser tester first confirms the pattern correctly captures addresses and does not incorrectly match phone numbers or partial strings that share some characters with email format.
Auditing a legacy validation rule that blocks new TLDs
A product manager reports that users with .photography or .technology email addresses cannot complete registration. The developer loads the existing validation regex into the tester and tests it against user@studio.photography. The pattern uses [a-zA-Z]{2,4} for the TLD component, which caps valid TLD length at four characters. Changing the upper bound from 4 to remove the cap entirely, producing {2,}, and retesting confirms the fix accepts all long-TLD addresses without opening the pattern to obviously invalid inputs.
Building a server-side pre-screen for a bulk email sender
Before dispatching to a large mailing list, a developer applies an email regex as a fast pre-screen to reject obviously malformed addresses before they reach the SMTP delivery layer. The pattern ^[\w.%+\-]+@[\w\-]+(\.[\w\-]+)+$ is tested against a representative sample of 100 real addresses from the list. Addresses that fail the pre-screen are flagged for manual review rather than silently rejected, preserving deliverability reputation by avoiding unnecessary bounce attempts at the mail server.
Use this page when you need to build, adapt, or verify a regex pattern for email address validation in a form, API, or data pipeline.
Get better results with these expert suggestions:
Use a two-stage validation strategy: regex plus confirmation email
Regex confirms that a string is shaped like an email address according to the rules encoded in the pattern. It cannot determine whether the domain has valid MX records, whether the mailbox actually exists, or whether the address accepts incoming mail. Use regex as the first gate to reject obviously malformed input at form submission time, then send a confirmation email with a verification link. This combination catches both syntax problems and non-existent addresses without requiring an overly complex pattern.
Allow plus-sign subaddressing unless you have a specific reason not to
Many users create inbox filters using plus-sign subaddresses like user+signup@gmail.com or user+newsletter@fastmail.com. Patterns that omit + from the local part character class will silently reject these legitimate addresses. Include + alongside letters, digits, dots, underscores, and hyphens in the local part class: [a-zA-Z0-9._%+\-]+ covers the overwhelming majority of real addresses actually in use.
Do not cap TLD length at three or four characters
ICANN introduced hundreds of generic TLDs after 2014, many of which are longer than four characters: .academy, .consulting, .technology, .photography, .international. Using {2,} instead of {2,4} or {2,6} in the TLD component of your pattern accepts any current or future TLD without meaningfully weakening the filter, since a string with no at sign or domain structure will still fail the earlier components of the pattern.
Test with internationally common email providers
Include addresses from providers that use subdomains or country-code second-level domains in your test set: user@mail.company.co.uk, contact@empresa.com.br, info@firma.de. These formats are entirely legitimate and widely used but expose patterns with overly restrictive domain component classes that incorrectly reject addresses with dots in the domain portion between the subdomain and the TLD.
More use-case guides for the same tool:
Open the full Regex Tester — free, no account needed, works on any device.
Open Regex Tester →Free · No account needed · Works on any device