Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Zod · Module

.email

z.email() creates a schema for validating email addresses. It uses a comparatively strict default pattern and accepts a custom pattern regular expression for alternative rules.

How it works

z.email() creates a Zod schema that checks whether input is an email address. Its default validator is comparatively strict; pass an options object with pattern when an application needs a different supported or custom regular expression.

Syntax

z.email(options?)

Parameters

NameTypeDescription
optionsobjectOptional configuration object; its pattern property supplies the regular expression used for email validation.
patternRegExpRegular expression used to customize email validation behavior.

Returns

A Zod email schema that validates input strings against the selected email regular expression.

Key points

  • Call z.email() to create a schema specifically for email-address validation.
  • Without options, validation uses a relatively strict pattern aimed at ordinary addresses with common characters.
  • The default behavior is approximately comparable to Gmail’s address rules, rather than guaranteeing every possible email syntax.
  • Customize matching by supplying a regular expression in the pattern option.
  • z.regexes.email represents the same default email pattern and can be passed explicitly.
  • Use z.regexes.unicodeEmail when a looser pattern that permits Unicode addresses is appropriate.

Common mistakes

  • Email syntax has no single universally appropriate regular expression, so choose the pattern that matches the application’s requirements.
  • Prefer the top-level z.email() form; the older chained method remains available but is deprecated.

Example: Validate an email field

import { z } from "zod";

const Contact = z.object({
  email: z.email({ pattern: z.regexes.html5Email }),
});

console.log(Contact.parse({ email: "dev@example.com" }));

Creates an object schema whose email field accepts a valid HTML5-style email address.

When to use it

Input validation

Validate an email field in a request, form, or configuration object.

Browser-aligned validation

Apply HTML5-compatible address rules.

Unicode email support

Permit internationalized email addresses.

Custom email policy

Enforce application-specific address syntax.

Interview questions

QHow do you validate an email address in current Zod?

Use z.email() to construct an email-validation schema, then parse input with the normal Zod parsing APIs. By default, it applies a comparatively strict regular expression for common email addresses.

Follow-up: How would you support a different email convention? Pass a custom regular expression through the pattern option, or select one of Zod’s exported regexes.

QHow can the email validation pattern be customized?

Pass an options object containing pattern, such as z.email({ pattern: z.regexes.html5Email }). This replaces the default matching behavior with the supplied regular expression.

Follow-up: Which built-in patterns are available? The documentation lists the default email regex, HTML5 email, RFC 5322-style, and Unicode-oriented patterns.

QWhy should new code use z.email() instead of z.string().email()?

The current API is the top-level z.email() function. Although z.string().email() still works, the documentation marks method forms as deprecated and says top-level string formats are more tree-shakable.

Follow-up: What migration should a codebase make? Replace chained .email() calls with z.email() while preserving surrounding object, optionality, or array composition.

  • z.regexes.email
  • z.regexes.html5Email
  • z.regexes.rfc5322Email
  • z.regexes.unicodeEmail
  • z.string().email()

Source: Defining schemas | Zod. Checked 2026-10-15.