String Validators in Zod

From the Zod cheat sheet · String Validation · verified Jul 2026

String Validators

Length, format, and pattern validators for strings

typescript
z.string().min(3);
z.string().max(20);
z.string().length(10);
z.email();
z.url();
z.uuid();
z.string().regex(/^[a-z]+$/);
💡 In Zod 4, format validators like z.email() are top-level functions, not z.string().email()
⚡ Chain string methods to build complex validators — they all return ZodString
📌 Use z.iso.datetime() for ISO 8601 strings and z.coerce.date() to convert to Date objects
🟢 String transformations like .trim() and .toLowerCase() apply during parsing
stringvalidationemailurl

Continue with Zod

Save the full cheat sheet or work through every related task.

Back to the full Zod cheat sheet