Skip to content
masterclass Buddy

Zod · Method

.endsWith

.endsWith() validates that a string finishes with a given substring. Add it to a z.string() schema and parse input to apply the check.

Last updated

Syntax

z.string().endsWith(suffix)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • z.string()
  • z.string().startsWith()
  • z.string().includes()
  • z.string().parse()

Source: Defining schemas | Zod. Checked 2026-11-03.