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:
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 fromclassic/schemas.ts. - Type helpers —
z.infer<typeof Schema>, plusz.input/z.output, which differ once a schema transforms or codecs its value. - Error utilities —
treeifyError,prettifyError,flattenError,formatError; see ../error-reference/. - JSON Schema interop —
toJSONSchemaandfromJSONSchemaconvert in both directions. - Registries —
registry()andglobalRegistryattach 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:
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 throwZodErrorsafeParse/safeParseAsync— return the{ success, data | error }union above, never throwencode/decode(+safeEncode,safeDecode, async forms) — run codec schemas in either direction, mapping betweeninput<T>andoutput<T>
How a parse call actually executes is traced in ../../how-it-works/parse-pipeline/.