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

Zod · Module

.toLowerCase

.toLowerCase() defines a Zod string schema that converts parsed strings to lowercase. It is a chainable string transformation.

How it works

.toLowerCase() is a chainable string-schema transform. During parsing, it converts the string value to lowercase, so the returned value is normalized rather than preserving the original casing.

Syntax

z.string().toLowerCase()

Returns

A Zod string schema that parses strings into lowercase values.

Key points

  • Call it directly after z.string() to define a lowercase-producing string schema.
  • The method appears in the string transformations section alongside whitespace trimming.
  • It has a complementary uppercase operation for schemas that require the opposite casing.
  • It is documented near Unicode normalization, making it suitable for composing string cleanup operations.

Common mistakes

  • This method belongs on a string schema; it is not documented as a general-purpose transform for arbitrary input types.

Example: Lowercase a parsed string

import { z } from "zod";

const username = z.string().toLowerCase();

console.log(username.parse("AdaLovelace")); // "adalovelace"

The schema accepts a string and transforms its parsed value to lowercase.

When to use it

Canonicalize identifiers

Normalize usernames or other case-insensitive identifiers before application logic consumes them.

Normalize input casing

Store or compare user-provided text using a consistent lowercase representation.

Interview questions

QWhat does .toLowerCase() do?

It creates a string schema that lowercases the value during parsing. For example, parsing "AdaLovelace" produces "adalovelace".

Follow-up: How would you combine it with length constraints? Chain the constraints and transform on the string schema, such as z.string().min(1).toLowerCase().

QWhere is this method used in a Zod schema?

It is used as a chainable method on z.string(). The documentation presents it alongside other string transformations such as trimming, uppercasing, and Unicode normalization.

Follow-up: When should normalization happen? Apply it in the schema when the normalized representation should be the value returned by parsing.

QWhat is the syntax and result of this method?

The documented declaration is z.string().toLowerCase(). It returns a schema whose parsed string value is lowercase.

Follow-up: What is a practical use? Normalize case-insensitive identifiers, such as usernames or email-like keys, before later application logic uses them.

  • z.string()
  • trim()
  • toUpperCase()
  • normalize()

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