About this tool
Copy-ready email regex patterns from minimal to RFC 5322-flavoured, with live testing and honest notes on what each one misses.
This library gives you five copy-ready regular expressions for email validation, ordered by strictness — from a minimal one-@ sanity check to the exact WHATWG HTML5 browser regex and an RFC 5322-flavoured pattern with quoted local parts and IPv4 domain literals. Each pattern comes with a live tester, example accept/reject strings, and an honest list of what it cannot catch, so developers can pick the right strictness for a signup form, an API validator or a data-cleaning script.
Open Regex Library for Email Validation on AltFTool — it loads instantly in your browser.
Paste your code or data sample into the workspace.
Pick the format, conversion, or analysis you need.
Copy the polished result straight back into your project.
Five graded patterns from loosest to RFC 5322-flavoured, so you match validation strength to the job.
Every pattern lists exactly which invalid addresses it still accepts and which valid ones it rejects.
Paste any address and see instantly whether the selected pattern accepts it before you copy the regex.
For most web forms, the WHATWG HTML5 pattern is the best default because it is the exact regex browsers apply to input type=email, so client and server agree. Stricter is not automatically better: the full RFC 5322 grammar accepts addresses like "john doe"@example.com that many mail systems reject, and the only real proof an address works is a confirmation email.
Because the HTML Standard deliberately allows dotless domains — the spec itself calls this a willful violation of RFC 5322, since intranet addresses like user@localhost are legitimate. If you only want public-internet addresses, use the hardened variant in this library that requires a final alphabetic label of 2–63 characters.
No practical regex can — RFC 5322 allows nested comments and folding whitespace that regular expressions cannot fully express, and even a syntactically perfect address may not exist. Regex should check format only; deliverability requires an MX lookup or a confirmation message.
RFC 5321 limits the local part (before the @) to 64 octets and the domain to 255 octets, with 254 characters as the practical maximum for the whole address. None of the common validation regexes enforce these limits, so add an explicit length check in code alongside the pattern.