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

Zod · Type Alias

ZodRawShape

ZodRawShape is the object-like map of property names to Zod schemas used to define Zod object fields. Use it directly as a reusable shape or pass it to z.object to create an object schema.

How it works

ZodRawShape is the structural type for the schema map supplied to an object schema. Each key names a property, and each value describes that property's validation rules; the map can be inspected through an object's .shape property and passed to z.object to construct the complete schema.

Syntax

type ZodRawShape = Record<string, ZodTypeAny>

Key points

  • The values in a raw shape are schemas, so each field can express validation for primitive or structured data.
  • An object schema exposes its field-schema map through .shape, allowing individual validators to be retrieved by property name.
  • Reading a named entry from .shape returns that property's Zod schema, which can be inspected or reused.
  • Different keys in one shape can use different schema types, such as a number validator for an age field.

Common mistakes

  • A raw shape describes the individual field schemas, not a complete object validator by itself; wrap it with z.object when you need to parse an object.

Example: Using a raw object shape

import { z } from "zod";

const shape = {
  name: z.string(),
  age: z.number().int(),
} satisfies z.ZodRawShape;

const Person = z.object(shape);
const person = Person.parse({ name: "Ada", age: 36 });

A raw shape is a plain object whose property values are Zod schemas; passing it to z.object creates an object schema.

When to use it

Object schema construction

Define an object schema from a reusable map of field validators.

Schema introspection

Retrieve or reuse individual field validators from an existing object schema.

Schema composition

Keep field definitions separate so related object schemas can share or extend them.

Interview questions

QWhat is ZodRawShape used for?

ZodRawShape is the shape of a Zod object: a mapping from property keys to Zod schemas. It is useful when defining or reusing the field-schema map before constructing an object schema with z.object.

Follow-up: How can you inspect an existing object's raw shape? Use its .shape property, which exposes the schemas for its individual keys.

QHow does a raw shape become a complete schema?

A raw shape contains validators for fields such as strings and numbers. z.object(shape) turns that mapping into a Zod object schema that can validate complete objects.

Follow-up: What does the resulting object schema provide? It can be used with Zod's parsing APIs to validate input and produce typed output.

QHow do you access the schemas inside an object?

The individual schemas are available through an object's .shape property. For example, accessing a name entry yields the schema associated with that key, rather than the parsed value.

Follow-up: Why is this useful? It lets code inspect or reuse field validators when composing related object schemas.

  • z.object
  • ZodObject
  • .shape
  • z.string
  • z.number

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