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

Zod · Module

.deepPartial

z.deepPartial() recursively makes properties optional throughout a Zod schema. Unlike .partial(), it can traverse nested structures such as objects, arrays, tuples, unions, records, and wrappers.

How it works

Pass a Zod schema to z.deepPartial() to recursively make properties optional throughout supported nested structures. The resulting schema still validates supplied values and can be used like other Zod object schemas, including parsing partial nested objects.

Syntax

z.deepPartial(schema)

Parameters

NameTypeDescription
schemaZod schemaThe Zod schema whose nested properties should be made optional recursively.

Returns

A transformed Zod schema; for an object input, the result is still a ZodObject with recursively optional properties.

Key points

  • The API is designed to make properties optional without manually rebuilding the schema.
  • The ordinary .partial() method is shallow and does not recursively alter nested properties.
  • z.deepPartial() applies optionality recursively throughout the schema tree.
  • Its documented traversal includes arrays, tuples, unions, records, and wrapper schemas.
  • When the input is an object schema, the transformed result retains the ZodObject type.
  • Object inspection and extension remain available after creating the deep partial schema.

Common mistakes

  • Unlike .partial(), this operation is recursive rather than limited to top-level properties.
  • The current documentation describes recursion through more than just nested objects, including arrays, tuples, unions, records, and wrappers.

Example: Deeply optional object schema

import { z } from "zod";

const Post = z.object({
  title: z.string(),
  author: z.object({ name: z.string(), email: z.string() }),
});

const PartialPost = z.deepPartial(Post);

PartialPost.parse({ author: {} });

Creates a schema in which nested object properties can be omitted while validating the supplied values.

When to use it

Partial updates

Validate PATCH or update payloads where any nested field may be omitted.

Incremental configuration

Accept incomplete nested configuration while preserving the original validation rules for supplied values.

Schema reuse

Derive a recursively optional form of an existing object schema instead of duplicating its shape.

Interview questions

QWhat does z.deepPartial() do?

z.deepPartial() accepts an existing Zod schema and returns a schema whose nested properties are optional recursively. For example, a nested author object can be validated with only the properties that are present.

Follow-up: How does it differ from .partial()? .partial() changes only the top-level shape, while z.deepPartial() continues through supported nested structures.

QWhich schema structures can z.deepPartial() traverse?

It can recurse through objects, arrays, tuples, unions, records, and wrappers. This makes it suitable for validating partially supplied data whose structure contains several nested schema types.

Follow-up: What limitation should be checked in older documentation? Older method-based documentation described narrower support, so the current API page should be preferred for the stable major version.

QWhat type of schema does z.deepPartial() return for an object input?

The result remains a ZodObject when applied to the documented object example. Therefore, object-specific APIs such as .shape and .extend() remain available on the result.

Follow-up: What practical benefit follows from retaining ZodObject? A partial schema can still be inspected or extended without converting it to an unrelated schema type.

  • z.partial()
  • z.object()
  • ZodObject.shape
  • ZodObject.extend()

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