Regex library
Regular expression for email addresses
A practical JavaScript regex for email addresses, with live tests. Not a full RFC 5322 parser — and that is intentional.
^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$
Runs 100% in your browser. Nothing you paste is uploaded, stored, or sent to a server.
Highlighted matches
How to use
- Scan the pre-filled pattern and the sample. Hits are highlighted; misses stay plain.
- Toggle flags if you need global or case-insensitive matching. The pattern is JavaScript / ECMAScript.
- Paste your own corpus. Nothing is sent to a server.
- Read the notes below before you drop the pattern into production — several of these are intentionally incomplete.
A perfect email regex is a trap. RFC 5322 allows quoted strings and comments that almost no mail server will deliver. This pattern matches the addresses people actually type: local-part, @, domain, and a two-or-more-letter TLD.
Use it for a first-pass form check, then let the mail API bounce the rest. The tester on this page is pre-filled so you can see a plus-tag and a rejection side by side.
What this pattern will not do
Does not allow IP-literal domains or quoted local parts.
TLD must be at least two letters; numeric TLDs will fail, which is usually what you want.
For production validation, prefer an HTML email input plus a confirmation mail.
FAQ
Why not implement RFC 5322?
The full grammar is huge and still will not tell you if the mailbox exists. A practical pattern plus a confirmation email is the reliable pair.
Does +tag addressing work?
Yes. The local part allows + so grace+news@example.com matches.
Is the sample text uploaded?
No. The tester compiles the pattern with the browser’s RegExp engine and stays on the device.