packages/docs/content/index.mdx
import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; import { Tabs } from 'fumadocs-ui/components/tabs';
import { Platinum } from '../components/platinum'; import { Gold } from '../components/gold'; import { Silver } from '../components/silver'; import { Bronze } from '../components/bronze'; import { HeroLogo } from '../components/hero-logo';
<div className="flex flex-col items-stretch text-center"> <HeroLogo /> <h1 className="text-3xl font-bold">Zod</h1> <p className="mt-2 mb-1">TypeScript-first schema validation with static type inference by <a href="https://x.com/colinhacks">@colinhacks</a> </p> <div className="flex flex-row flex-wrap justify-center gap-1 py-2"> <a className="border-none" href="https://github.com/colinhacks/zod/actions?query=branch%3Amain"></a>
<a className="border-none" href="https://twitter.com/colinhacks" rel="nofollow">
</a>
<a className="border-none" href="https://opensource.org/licenses/MIT" rel="nofollow">
</a>
<a className="border-none" href="https://www.npmjs.com/package/zod" rel="nofollow">
</a>
<a className="border-none" href="https://github.com/colinhacks/zod" rel="nofollow">
</a>
{/* <ParamField path="param" type="string"> An example of a parameter field </ParamField>
<ParamField query="filter" type="string" default="none" required> The filtering command used to sort through the users </ParamField> <ParamField body="user_age" type="integer" default="0" required> The age of the user. Cannot be less than 0 </ParamField> */} <div className="mt-5 font-gray-100 mx-auto text-center pt-12"> <span className=""> Zod 4 is stable. Read the <a rel="noopener noreferrer" href="/v4" alt="zod 4 release notes">release notes</a> and <a rel="noopener noreferrer" href="/v4/changelog" alt="zod 4 migration guide">migration guide</a>. </span> </div>Zod is a TypeScript-first validation library. Using Zod, you can define schemas you can use to validate data, from a simple string to a complex nested object.
import * as z from "zod";
const User = z.object({
name: z.string(),
});
// some untrusted data...
const input = { /* stuff */ };
// the parsed result is validated and type safe!
const data = User.parse(input);
// so you can use it with confidence :)
console.log(data.name);
npm install zod
Zod is also available as
@zod/zodon jsr.io.
Zod provides an MCP server that can be used by agents to search Zod's docs. To add to your editor, follow these instructions. Zod also provides an llms.txt file.
Zod is tested against TypeScript v5.5 and later. Older versions may work but are not officially supported.
"strict"You must enable strict mode in your tsconfig.json. This is a best practice for all TypeScript projects.
// tsconfig.json
{
// ...
"compilerOptions": {
// ...
"strict": true
}
}
Zod has a thriving ecosystem of libraries, tools, and integrations. Refer to the Ecosystem page for a complete list of libraries that support Zod or are built on top of it.
I also contribute to the following projects, which I'd like to highlight:
tsc.Sponsorship at any level is appreciated and encouraged. If you built a paid product using Zod, consider one of the corporate tiers.