{"schemaVersion":"1.0","record":{"label":"Zod","description":"MIT-licensed JavaScript and TypeScript schema-validation library with runtime parsing and static type inference.","aliases":[],"kind":"software","website":"https://zod.dev/","overview":"Zod is an open-source schema-validation library that checks data at runtime and infers TypeScript types from the same schema definitions. It can be used for structured inputs such as API payloads, forms and configuration. In AI-assisted development, a schema makes some expectations executable, but passing a shape check does not establish that the data is truthful, authorized or correct for the application's business rules.","license":"MIT","lifecycle":"active","example":false,"features":[{"name":"Runtime parsing and inferred types","status":"supported","detail":"Schema parsing validates unknown input and returns the parsed result; inferred input/output types may differ after transformations.","useCase":"Runtime validation of application inputs and data boundaries","platforms":["Node.js","Modern web browsers","JavaScript","TypeScript"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://zod.dev/basics","locator":"parse/safeParse, async variants and distinct input/output types","retrievedAt":"2026-10-07T22:49:54Z","kind":"vendor"}]},{"name":"Object-key policy","status":"supported","detail":"Default objects strip extra keys; strict and loose schemas explicitly reject or preserve them.","useCase":"Runtime validation of application inputs and data boundaries","platforms":["Node.js","Modern web browsers","JavaScript","TypeScript"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://zod.dev/api","locator":"Object unknown-key policy, strict/loose objects and coercion","retrievedAt":"2026-10-07T22:50:17Z","kind":"vendor"}]},{"name":"Lossless JSON Schema conversion","status":"limited","detail":"Some Zod types and transformations cannot be represented; permissive fallback can discard constraints and import remains experimental.","useCase":"Runtime validation of application inputs and data boundaries","platforms":["Node.js","Modern web browsers","JavaScript","TypeScript"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://zod.dev/json-schema","locator":"Unrepresentable types, input/output conversion and experimental import","retrievedAt":"2026-10-07T22:49:13Z","kind":"vendor"}]},{"name":"Bundle-oriented functional variant","status":"supported","detail":"Zod Mini exposes functional APIs designed for tree shaking; actual savings depend on the schemas and build.","useCase":"Runtime validation of application inputs and data boundaries","platforms":["Node.js","Modern web browsers","JavaScript","TypeScript"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://zod.dev/packages/mini","locator":"Functional tree-shakable API and workload-specific bundle comparison","retrievedAt":"2026-10-07T22:49:13Z","kind":"vendor"}]}],"alternatives":[],"slug":"zod","draftAlternatives":[{"targetSlug":"valibot","status":"limited","detail":"Can substitute for runtime data validation and inferred TypeScript schemas, with a different API and error/output handling. Existing pipelines need translation and behavioral tests.","useCase":"Runtime validation of application inputs and data boundaries","platforms":["Node.js","Modern web browsers","JavaScript","TypeScript"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://zod.dev/","locator":"Runtime schema validation, TypeScript requirements and JavaScript support","retrievedAt":"2026-10-07T22:48:59Z","kind":"vendor"},{"url":"https://zod.dev/basics","locator":"parse/safeParse, async variants and distinct input/output types","retrievedAt":"2026-10-07T22:49:54Z","kind":"vendor"},{"url":"https://valibot.dev/guides/introduction/","locator":"Modular schema/validation functions and runtime validation","retrievedAt":"2026-10-07T22:48:59Z","kind":"vendor"}]}],"evidence":[{"url":"https://zod.dev/","locator":"Runtime schema validation, TypeScript requirements and JavaScript support","retrievedAt":"2026-10-07T22:48:59Z","kind":"vendor"},{"url":"https://github.com/colinhacks/zod/blob/main/LICENSE","locator":"MIT license","retrievedAt":"2026-10-07T22:49:54Z","kind":"vendor"},{"url":"https://zod.dev/basics","locator":"parse/safeParse, async variants and distinct input/output types","retrievedAt":"2026-10-07T22:49:54Z","kind":"vendor"},{"url":"https://zod.dev/api","locator":"Object unknown-key policy, strict/loose objects and coercion","retrievedAt":"2026-10-07T22:50:17Z","kind":"vendor"},{"url":"https://zod.dev/json-schema","locator":"Unrepresentable types, input/output conversion and experimental import","retrievedAt":"2026-10-07T22:49:13Z","kind":"vendor"},{"url":"https://zod.dev/packages/mini","locator":"Functional tree-shakable API and workload-specific bundle comparison","retrievedAt":"2026-10-07T22:49:13Z","kind":"vendor"},{"url":"https://zod.dev/v4/changelog","locator":"Error API changes and defaults inside optional fields","retrievedAt":"2026-10-07T22:50:17Z","kind":"vendor"},{"url":"https://valibot.dev/guides/introduction/","locator":"Modular schema/validation functions and runtime validation","retrievedAt":"2026-10-07T22:48:59Z","kind":"vendor"}],"document":{"version":1,"references":[{"url":"https://zod.dev/","locator":"Runtime schema validation, TypeScript requirements and JavaScript support","retrievedAt":"2026-10-07T22:48:59Z","id":"intro","title":"Zod introduction","kind":"vendor"},{"url":"https://github.com/colinhacks/zod/blob/main/LICENSE","locator":"MIT license","retrievedAt":"2026-10-07T22:49:54Z","id":"license","title":"Zod license","kind":"vendor"},{"url":"https://zod.dev/basics","locator":"parse/safeParse, async variants and distinct input/output types","retrievedAt":"2026-10-07T22:49:54Z","id":"basics","title":"Zod basic usage","kind":"vendor"},{"url":"https://zod.dev/api","locator":"Object unknown-key policy, strict/loose objects and coercion","retrievedAt":"2026-10-07T22:50:17Z","id":"api","title":"Zod schema API","kind":"vendor"},{"url":"https://zod.dev/json-schema","locator":"Unrepresentable types, input/output conversion and experimental import","retrievedAt":"2026-10-07T22:49:13Z","id":"json","title":"Zod JSON Schema conversion","kind":"vendor"},{"url":"https://zod.dev/packages/mini","locator":"Functional tree-shakable API and workload-specific bundle comparison","retrievedAt":"2026-10-07T22:49:13Z","id":"mini","title":"Zod Mini","kind":"vendor"},{"url":"https://zod.dev/v4/changelog","locator":"Error API changes and defaults inside optional fields","retrievedAt":"2026-10-07T22:50:17Z","id":"migration","title":"Zod 4 migration guide","kind":"vendor"},{"url":"https://valibot.dev/guides/introduction/","locator":"Modular schema/validation functions and runtime validation","retrievedAt":"2026-10-07T22:48:59Z","id":"valibot","title":"Valibot introduction","kind":"vendor"}],"overviewCitations":["intro","basics","api"],"licenseCitations":["license"],"sections":[{"id":"runtime","heading":"An executable boundary for unknown data","paragraphs":[{"id":"runtime-detail","content":[{"text":"A TypeScript annotation and a runtime check do different work. Zod schemas are executed against values, and parse returns the validated result or throws an error with issue details. safeParse instead returns a result that distinguishes success from failure. Code should use that parsed result, especially when a schema transforms data, rather than validate one value and continue using a different unchecked object. Asynchronous checks require the corresponding asynchronous parsing path."}],"citations":["basics"]}]},{"id":"objects","heading":"Unknown keys are a policy choice","paragraphs":[{"id":"objects-detail","content":[{"text":"An ordinary object schema removes unrecognized keys from its output. A strict object rejects extras, while a loose object preserves them; a catchall can validate additional values against a specified schema. These are meaningfully different contracts for an API. An assistant adding validation should not silently change a public payload's behavior by selecting the wrong object mode. Coercion also deliberately converts values and should be chosen according to the accepted input contract rather than used merely to make a test pass."}],"citations":["api"]}]},{"id":"interchange","heading":"JSON Schema is not a lossless serialization of every schema","paragraphs":[{"id":"interchange-detail","content":[{"text":"Zod has built-in JSON Schema export, but types such as dates, maps and arbitrary transformations do not have direct equivalents. Export normally rejects unrepresentable cases; a permissive fallback can instead erase restrictions. The documentation also distinguishes exporting input from output schemas when parsing changes the type. Importing JSON Schema through fromJSONSchema is explicitly experimental. These limits matter when reusing validation definitions in an API description or structured-output interface: matching the transport format is separate from preserving all runtime behavior."}],"citations":["json"]}]},{"id":"size","heading":"Regular Zod and Zod Mini","paragraphs":[{"id":"size-detail","content":[{"text":"Regular Zod offers chainable convenience methods. Zod Mini expresses more operations as independent functions so that unused code can be removed by a bundler. The project presents Mini as a variant with the same functionality rather than an unrelated validator, but code syntax changes when using it. Its documentation recommends evaluating actual bundle requirements rather than assuming a small published example predicts every application's cost."}],"citations":["mini"]}]},{"id":"upgrades","heading":"Version-aware generated code","paragraphs":[{"id":"upgrades-detail","content":[{"text":"The inspected introduction tests TypeScript 5.5 and later and requires strict mode for TypeScript projects. The v4 migration guide changes error customization and documents behavioral differences, including applying defaults inside optional object fields. Thus an older generated schema can need more than an import update: accepted inputs, returned values and displayed errors should be checked. A compiler success alone does not establish that a migration preserved the original data contract."}],"citations":["intro","migration"]}]},{"id":"comparison","heading":"License and substitution","paragraphs":[{"id":"comparison-detail","content":[{"text":"Zod is MIT-licensed and can replace "},{"text":"Valibot","targetSlug":"valibot"},{"text":" for overlapping runtime-validation tasks. Their schema construction, parsing results and error models differ, so existing callers and refinements need adaptation. The useful scope is checking declared structure and constraints; neither library automatically supplies authentication, permissions or truthful source data. Selection should account for the application's integrations and measured build requirements. No package execution or comparative benchmark was performed for this article."}],"citations":["license","basics","valibot","mini"]}]}]},"id":"Q54","revision":38,"updatedAt":"2026-10-08T23:22:42Z","sourceUrl":"https://substitutefor.net/entities/Q54?revision=38"}}