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

Zod · Module

.partial

.partial() derives a Zod object schema with optional properties. Use it without arguments for all fields, or provide a mask to make only selected fields optional.

How it works

Use .partial() on a Zod object to derive another object schema whose properties are optional. Call it without arguments to make every property optional, or pass a shape of boolean flags to limit optionality to selected keys.

Syntax

schema.partial(mask?)

Parameters

NameTypeDescription
maskPartial<Record<keyof Shape, true>>Optional shape whose true-valued keys identify the object properties to make optional.

Returns

A new Zod object schema with all properties optional, or with only the properties selected by the mask optional.

Key points

  • .partial() returns a new object schema with optional properties, either for all fields or for a selected subset.
  • The API follows the same broad idea as TypeScript's Partial utility type.
  • Calling .partial() with no arguments makes every property in the object schema optional.
  • The result preserves each field's underlying value schema while changing its requiredness.
  • A boolean shape argument lets you target individual properties instead of making the entire object partial.
  • Explicitly declared symbol properties participate in .partial() like other supported object-shape operations.

Common mistakes

  • Use z.partialRecord() for partial record types rather than applying .partial() to a record schema.
  • The method also handles symbol keys that are explicitly declared in the object shape.

Example: Make a selected object field optional

import { z } from "zod";

const User = z.object({
  email: z.string().email(),
  username: z.string(),
});

const UserPatch = User.partial({ username: true });

console.log(UserPatch.parse({ email: "a@example.com" }));

Creates a schema for updates where only the selected username field becomes optional.

When to use it

Partial updates

Accepting PATCH-style payloads where any user field may be updated.

Draft forms

Reusing a required creation schema for a form whose fields are progressively completed.

Selective configuration overrides

Allowing a subset of configuration values while retaining required defaults or identifiers.

Interview questions

QWhat does Zod's .partial() method do?

.partial() derives an object schema with optional properties. With no arguments, every property becomes optional; passing a boolean-keyed shape restricts the change to selected fields.

Follow-up: How would you model a partial record? Use z.partialRecord(); the documentation recommends it for partial record types.

QHow can you make only selected fields optional?

Call .partial({ fieldName: true }) to make only the named fields optional while leaving the other fields required. The returned schema is still an object schema and can be parsed normally.

Follow-up: What happens when a requested partial key is not declared? The documentation states that undeclared symbol keys are ignored; for ordinary object keys, use keys from the schema shape.

QIs .partial() the same as a deep partial?

.partial() is modeled after TypeScript's Partial utility and changes optionality at the object-property level. It does not mean that nested object properties automatically become optional.

Follow-up: What API should be considered when nested structures also need optional fields? Check the documentation for the appropriate deep-partial facility rather than assuming .partial() recurses.

  • z.object
  • z.partialRecord
  • z.pick
  • z.omit
  • z.extend
  • z.exactPartial

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