How to Validate an Email Address Format
Validating email addresses is a common requirement for web forms, APIs, and user registration flows. But email validation is deceptively complex — the official RFC 5322 specification allows patterns that no one would practically use. This guide covers practical approaches to email validation that balance correctness with usability.
Why Email Validation Is Hard
The RFC 5322 standard defines valid email addresses like these:
user@example.com first.last@subdomain.example.co.uk user+tag@example.org "very.unusual.@.unusual.com"@example.com
A fully RFC-compliant regex is thousands of characters long. In practice, a simpler validation strategy works better for most applications.
A Practical Regex Pattern
Most developers use a simplified regex that covers 99% of real-world email addresses:
/^[^\s@]+@[^\s@]+\.[^\s@]+$/
This pattern checks that there is a local part, an @ symbol, and a domain with at least one dot. It rejects obviously invalid inputs without being overly restrictive.
How to Validate an Email Step by Step
- 1Trim whitespace. Remove leading and trailing spaces before validation, as users often accidentally add spaces when copying.
- 2Apply the regex. Use a practical pattern like the one above to check the basic format. Test it with the ToolStack Regex Tester.
- 3Verify the domain (optional). For critical applications, check that the domain has valid MX records to confirm it can receive email.
- 4Send a confirmation email. The only way to truly verify an email address exists is to send a verification link.
Try It: Test Your Regex Online
Use the ToolStack Regex Tester to test email validation patterns against sample inputs in real time.
Open Regex Tester