Free tool

Email regex tester

Test an email regex against a list of addresses, start from a recommended pattern, and see what each one accepts. A regex only checks the shape of an address: it can't tell whether the domain takes mail or whether the inbox is a throwaway.

RegExp · runs in your browser

7 of 15 match · 15 of 15 known cases as expected

  • Matches: ana@example.complain address
  • Matches: ana.lima+promo@gmail.comdots and a +tag are valid
  • Matches: o'brien@example.ieapostrophes are allowed
  • Matches: user@mail.example.co.uksubdomains and two-part suffixes
  • Matches: user@xn--bcher-kva.exampleinternationalized domain (punycode)
  • No match: ana..lima@example.comtwo dots in a row
  • No match: .ana@example.comlocal part starts with a dot
  • No match: ana@exampleno top-level domain
  • No match: ana@-example.comlabel starts with a hyphen
  • No match: ana@example.cone-letter top-level domain
  • No match: ana lima@example.comunquoted space
  • No match: ana@@example.comtwo @ signs
  • No match: "ana lima"@example.comvalid in RFC 5322, never handed out
  • Matches: qwe@mailinator.comvalid syntax, but disposable
  • Matches: jane@gmial.comvalid syntax, but a typo of gmail.com

Valid syntax isn't a real inbox. Check every sign-up with one API call. Free for 7 days or 1,000 checks, no card.

Start free trial

The recommended pattern reads in three parts:

  • Local part (before the @): letters, digits and the symbols RFC 5322 allows (such as +, ', !, # and =), in dot-separated runs. No leading, trailing or double dots. Quoted local parts like "john doe"@example.com are valid under RFC 5322 but almost never real, so they're left out.
  • Domain labels: 1 to 63 letters, digits or hyphens, not starting or ending with a hyphen, each followed by a dot.
  • Top-level domain: 2 to 63 letters, or an internationalized xn-- label. This rejects user@localhost and user@example.c.

What no regex can check

A pattern that matches perfectly still accepts qwe@mailinator.com (a disposable inbox), ana@gmial.com (a typo of a real provider), and ana@no-such-domain-4821.com (a domain with no mail servers). All three pass every regex on this page.

Checking those takes data and DNS: a list of disposable domains, the domain's MX records, and a typo check against common providers. That's what the disposable email checker and the AntiBurner API do after the syntax check. More in Email regex: why validation regex isn't enough.

Length limits

Keep length checks outside the regex, where they're readable: at most 64 characters before the @ and at most 254 for the whole address (the limit that fits an SMTP path). Trim surrounding spaces before you validate, and lowercase the domain before you compare it with anything.

Copy the recommended email regex

The same pattern in JavaScript, with the length limits checked outside the regex. It needs no lookbehind, so it also works in most other regex engines.

email.ts
const EMAIL = /^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+(?:[a-z]{2,63}|xn--[a-z0-9-]{1,59})$/i;

export function looksLikeEmail(input: string): boolean {
  const email = input.trim();
  const at = email.lastIndexOf("@");
  if (at < 1 || at > 64 || email.length > 254) return false;
  return EMAIL.test(email);
}

The HTML spec pattern is what browsers use for an input with type="email". It allows consecutive dots in the local part and a domain without a dot, which is why the tester shows it accepting a few addresses no provider hands out.

html-spec.js
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/

Questions

What is the best regex for email validation?

One that accepts every address people really use and rejects obvious mistakes: a dot-atom local part, domain labels of letters, digits and hyphens, and a real-looking top-level domain. The recommended pattern on this page does that. Then check the domain with DNS, because no regex knows whether it receives mail.

What regex does the HTML email input use?

The HTML standard defines input type="email" with a pattern that allows the usual local-part characters and LDH domain labels, but doesn't require a dot in the domain, so user@localhost passes. It's included in the tester as the HTML spec pattern.

Can a regex validate every RFC 5322 email address?

Technically close, but the result is thousands of characters long and accepts addresses no mail provider hands out, such as quoted strings with spaces or comments. Practical validation deliberately accepts a smaller, real-world subset.

Does a regex check if an email address exists?

No. A regex only checks the format. Whether the domain receives mail needs a DNS lookup, whether it's a throwaway needs a disposable-domain list, and whether the mailbox exists can only be confirmed by sending a verification email.

Related guides

Valid syntax isn't a real user.

One call tells you if the domain takes mail or is a throwaway.

  • 7-day free trial
  • 1,000 checks included
  • No card
  • Then from $9 a month