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

Zod · Module

.omit

.omit() derives a Zod object schema without selected keys. Pass a mask with the keys to remove set to true.

How it works

.omit() creates a new object schema by removing the keys marked true in its mask. The resulting schema validates the remaining fields and infers a corresponding TypeScript object type, making it useful for derived shapes such as public or update payloads.

Syntax

objectSchema.omit(mask)

Parameters

NameTypeDescription
maskobject maskAn object mask whose properties set to true identify the keys to remove.

Returns

A new Zod object schema with the masked keys omitted.

Key points

  • Zod object schemas expose dedicated APIs for deriving shapes by keeping or removing selected keys.
  • Call .omit() on an object schema to remove selected properties.
  • The mask marks each property to remove with the boolean value true.
  • The API follows the same general idea as TypeScript's Pick and Omit utility types.

Common mistakes

  • Symbol keys declared in the object shape are supported by .omit().
  • A symbol key absent from the original shape is ignored rather than being added or preserved.

Example: Omit an object key

import { z } from "zod";

const Recipe = z.object({
  id: z.string(),
  name: z.string(),
  ingredients: z.array(z.string()),
});

const RecipeNoId = Recipe.omit({ id: true });

console.log(RecipeNoId.parse({
  name: "Pasta",
  ingredients: ["pasta", "tomatoes"],
}));

Creates a recipe schema variant that validates and returns only the name and ingredients fields.

When to use it

Input payloads

Create a request schema without server-managed identifiers or metadata.

Data exposure control

Build a public-facing shape that excludes private object properties.

Schema variants

Reuse a base schema while defining update or create variants with different fields.

Interview questions

QWhat does Zod's .omit() method do, and how is it called?

.omit() is an object-schema method that returns a modified schema with selected keys removed. Pass an object mask whose selected properties are set to true, such as Recipe.omit({ id: true }).

Follow-up: How would you derive a schema that retains only a chosen subset? Use .pick() with a mask of the keys to keep instead of .omit().

QWhat happens to the inferred TypeScript type after omitting a key?

The result is a new object schema whose inferred type excludes the omitted properties. For example, omitting id from a recipe leaves a type containing name and ingredients.

Follow-up: What TypeScript utility type is this API conceptually related to? It parallels TypeScript's built-in Omit utility type.

QWhen is .omit() useful in application schema design?

Use .omit() when a base object schema contains fields that should not appear in a derived shape, such as removing an identifier from a create or transport payload. The method lets the derived schema reuse the remaining field definitions.

Follow-up: What alternative is appropriate when the derived shape should be assembled from unrelated fields? Define a separate z.object() schema or compose schemas with the object APIs documented by Zod.

  • z.object()
  • z.pick()
  • z.infer
  • z.partial()
  • z.extend()

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