Entry points

The exports map in packages/zod/package.json defines every way the package can be imported:

Import What you get
zod (.) Zod 4 classic — the full z namespace most applications use
zod/mini The tree-shakable variant: functions instead of methods, smallest bundles
zod/v4 Explicit alias for Zod 4 classic
zod/v4-mini, zod/v4/mini Explicit aliases for Mini
zod/v4/core The shared internals both variants are built on (schema classes prefixed $Zod)
zod/v3 The previous major, kept importable for incremental migration
zod/locales, zod/v4/locales Translated error messages

Classic and Mini are two frontends over one core: src/v4/classic/ and src/v4/mini/ both re-export machinery from src/v4/core/. That is why a ZodError thrown by one is structurally identical to the other's.

What the top-level export re-exports

The main entry is assembled in one file:

packages/zod/src/v4/classic/external.ts
export * as core from "../core/index.js";
export * from "./schemas.js";
export * from "./checks.js";
export * from "./errors.js";
export * from "./parse.js";
export * from "./compat.js";
// …
export type { infer, output, input } from "../core/index.js";
export {
  globalRegistry,
  registry,
  config,
  // …
  treeifyError,
  prettifyError,
  formatError,
  flattenError,
  NEVER,
} from "../core/index.js";
export { toJSONSchema } from "../core/json-schema-processors.js";
export { fromJSONSchema } from "./from-json-schema.js";

Notable groups:

  • Schema constructors (z.string, z.object, z.discriminatedUnion, …) come from classic/schemas.ts.
  • Type helpersz.infer<typeof Schema>, plus z.input/z.output, which differ once a schema transforms or codecs its value.
  • Error utilitiestreeifyError, prettifyError, flattenError, formatError; see ../error-reference/.
  • JSON Schema interoptoJSONSchema and fromJSONSchema convert in both directions.
  • Registriesregistry() and globalRegistry attach metadata to schemas without changing their types.

This file is also where the English locale is installed at import time (config(en())), which is why error messages work with zero configuration.

Parsing functions

Every schema method has a top-level functional twin defined in classic/parse.ts — this is the API Mini users call directly:

packages/zod/src/v4/classic/parse.ts
export type ZodSafeParseResult<T> = ZodSafeParseSuccess<T> | ZodSafeParseError<T>;
export type ZodSafeParseSuccess<T> = { success: true; data: T; error?: never };
export type ZodSafeParseError<T> = { success: false; data?: never; error: ZodError<T> };

export const parse: <T extends core.$ZodType>(
  schema: T,
  value: unknown,
  // …
) => core.output<T> = /* @__PURE__ */ core._parse(ZodRealError);

The full set, each with an async variant for schemas containing async refinements:

  • parse / parseAsync — return typed data or throw ZodError
  • safeParse / safeParseAsync — return the { success, data | error } union above, never throw
  • encode / decode (+ safeEncode, safeDecode, async forms) — run codec schemas in either direction, mapping between input<T> and output<T>

How a parse call actually executes is traced in ../../how-it-works/parse-pipeline/.

Sources: packages/zod/package.json, packages/zod/src/v4/classic/external.ts, packages/zod/src/v4/classic/parse.ts · last synced 2026-08-10 · 2d90846 · version 4.4.3