What Is a Good Regex for Email Validation?

A practical email regex: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$. This pattern covers the vast majority of real-world email addresses. A fully RFC 5322-compliant regex would be thousands of characters long and is rarely needed in practice.

Breaking Down the Pattern

PartMeaning
^Start of string
[a-zA-Z0-9._%+-]+Local part: letters, digits, dots, underscores, %, +, -
@Literal @ separator
[a-zA-Z0-9.-]+Domain: letters, digits, dots, hyphens
\.Literal dot before TLD
[a-zA-Z]{2,}$TLD: 2+ letters (com, org, io, etc.)

Usage Examples

JavaScript

const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
emailRegex.test('user@example.com');   // true
emailRegex.test('invalid@');           // false

Python

import re
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
bool(re.match(pattern, 'user@example.com'))  # True

Best Practice

Use regex for basic format checking, but the only true validation is sending a confirmation email. Also consider using <input type="email"> in HTML5 for browser-native validation.

Try It Yourself

Test this regex with our Regex Tester.

Frequently Asked Questions

Should I use regex alone to validate emails?

No. Regex can check the format, but the only way to truly validate an email is to send a confirmation email. Use regex for basic format checking, then verify by sending an actual message.

Does the HTML5 email input validate emails?

Yes. <input type="email"> uses a built-in regex following a subset of RFC 5322. It is a good first layer of validation but should still be combined with server-side checks.

Built by Michael Lip. 100% client-side — no data leaves your browser.