Email Regex Pattern: Validate Email Addresses Correctly

The Simple Email Regex

For most applications, a simple regex is enough. It checks for the basic structure: characters, an @ symbol, a domain, and a top-level domain:

/^[^\s@]+@[^\s@]+\.[^\s@]+$/

This pattern works for 99% of real-world email addresses and avoids false rejections on valid but unusual addresses.

Test the Pattern in JavaScript

const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

// Valid emails
emailRegex.test("user@example.com");      // true
emailRegex.test("name.surname@company.io"); // true
emailRegex.test("user+tag@gmail.com");    // true
emailRegex.test("x@y.z");                 // true

// Invalid emails
emailRegex.test("user@");                  // false
emailRegex.test("@example.com");           // false
emailRegex.test("user@example");           // false
emailRegex.test("user @example.com");      // false

Why Not Use the RFC 5322 Regex?

The full RFC 5322 regex is over 6,000 characters long and matches edge cases like "very.unusual.@.unusual.com"@example.com. In practice, these addresses are rejected by most email providers anyway. A simple regex avoids rejecting valid emails and is far easier to maintain.

Best practice: Use regex for format validation, then send a confirmation email to verify the address actually exists.

Common Pitfalls

  • Single quotes: Email addresses never contain single quotes — reject them.
  • Spaces: Spaces in emails are invalid — your regex should reject them.
  • Leading/trailing dots: .user@example.com and user.@example.com are technically invalid per RFC but may slip through simple patterns.
  • Unicode domains: IDN emails like user@münchen.de require punycode conversion before validation.

Test your regex pattern with live examples?

Use the Regex Tester tool