Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: 3 with issuesSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

String formats in Zod: email, UUID, phone, datetime

Zod has ready-made schemas for common string formats. You don't need to write your own regex for emails, IDs, phone numbers or timestamps.

All Zod examples Zod: usage and stats

String formats in Zod: email, UUID, phone, datetime: screenshot of the example below running
The code below, running in Chromium on our server (Oct 12, 2026). Press Run to see it live and change it.

How it works

  1. Validate emails. z.email() checks email addresses. The code tests one normal address and one without a domain. [1]
  2. Validate UUID v4. z.uuidv4() is listed as a convenience form of z.uuid({ version: "v4" }). The code tests a v4 UUID and a plain string. [1]
  3. Validate phone numbers. z.e164() checks phone numbers in E.164 format. The code tests a +1 number and a dashed local number. [1]
  4. Validate ISO datetimes. z.iso.datetime() is tested with a UTC timestamp and one with a +02:00 offset. Passing { offset: true } makes a second schema that also accepts offsets. [1]

Run and edit it

It runs in your browser, in a sandboxed frame that cannot see this site; the packages load from esm.sh only after you press Run.

import * as z from "zod";

const checks = [
  ["email", z.email(), "billie@example.com"],
  ["email", z.email(), "billie@"],
  ["uuidv4", z.uuidv4(), "123e4567-e89b-42d3-a456-426614174000"],
  ["uuidv4", z.uuidv4(), "not-a-uuid"],
  ["e164", z.e164(), "+15555555555"],
  ["e164", z.e164(), "555-555-5555"],
  ["iso.datetime", z.iso.datetime(), "2020-01-01T06:15:00Z"],
  ["iso.datetime", z.iso.datetime(), "2020-01-01T06:15:00+02:00"],
  ["iso.datetime offset", z.iso.datetime({ offset: true }), "2020-01-01T06:15:00+02:00"],
];

for (const [name, schema, value] of checks) {
  const ok = schema.safeParse(value).success;
  console.log(`${ok ? "PASS" : "FAIL"}  ${name}: ${value}`);
}
Ctrl/⌘ + Enter runs

Free for signed-in members, with a daily limit. Describe the change in plain words; the new code runs only in your browser.

Each line prints the format name, the value and whether it passed. Code written by AgentGid [1].

Checked Oct 12, 2026: it starts without errors in Chromium with zod 4.6.6. Needs WebGL.

More Zod examples

Handling errors with ZodError in Zod String validation in Zod Type coercion in Zod Literal values in Zod

Sources

  1. Docs: Defining schemas

Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.

Building something with Zod? Ask AgentGid →