Files
Colin McDonnellandGitHub 17df521cdb Clean up docs navigation and stale labels (#5901)
* docs: clean up current docs navigation

* docs: document E.164 phone numbers
2026-04-29 16:40:35 -07:00

184 lines
5.8 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Intro"
mode: "center"
description: "Introduction to Zod - TypeScript-first schema validation library with static type inference"
---
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<br/>by <a href="https://x.com/colinhacks">@colinhacks</a> </p>
<br/>
<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">
<img className="h-[20px] m-0!" src="https://github.com/colinhacks/zod/actions/workflows/test.yml/badge.svg?event=push&branch=main" alt="Zod CI status" />
</a>
<a className="border-none" href="https://twitter.com/colinhacks" rel="nofollow">
<img className="h-[20px] m-0!" src="https://img.shields.io/badge/created%[email protected]" alt="Created by Colin McDonnell" />
</a>
<a className="border-none" href="https://opensource.org/licenses/MIT" rel="nofollow">
<img className="h-[20px] m-0!" src="https://img.shields.io/github/license/colinhacks/zod" alt="License" />
</a>
<a className="border-none" href="https://www.npmjs.com/package/zod" rel="nofollow">
<img className="h-[20px] m-0!" src="https://img.shields.io/npm/dw/zod.svg" alt="npm" />
</a>
<a className="border-none" href="https://github.com/colinhacks/zod" rel="nofollow">
<img className="h-[20px] m-0!" src="https://img.shields.io/github/stars/colinhacks/zod" alt="stars" />
</a>
</div>
<div className="flex flex-row justify-center gap-1">
<a href="https://zod.dev">Website</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://discord.gg/RcG33DQJdf">Discord</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://twitter.com/colinhacks">𝕏</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://bsky.app/profile/zod.dev">Bluesky</a>
<br />
</div>
</div>
<br/>
{/* <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>
<br /><br /><br />
## Introduction
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.
```ts
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);
```
## Features
- Zero external dependencies
- Works in Node.js and all modern browsers
- Tiny: 2kb core bundle (gzipped)
- Immutable API: methods return a new instance
- Concise interface
- Works with TypeScript and plain JS
- Built-in JSON Schema conversion
- Extensive ecosystem
## Installation
```sh
npm install zod
```
> Zod is also available as `@zod/zod` on [jsr.io](https://jsr.io/@zod/zod).
Zod provides an MCP server that can be used by agents to search Zod's docs. To add to your editor, follow [these instructions](https://share.inkeep.com/zod/mcp). Zod also provides an [llms.txt](https://zod.dev/llms.txt) file.
## Requirements
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.
```ts
// tsconfig.json
{
// ...
"compilerOptions": {
// ...
"strict": true
}
}
```
## Ecosystem
Zod has a thriving ecosystem of libraries, tools, and integrations. Refer to the [Ecosystem page](/ecosystem) for a complete list of libraries that support Zod or are built on top of it.
- [Resources](/ecosystem?id=resources)
- [API Libraries](/ecosystem?id=api-libraries)
- [Form Integrations](/ecosystem?id=form-integrations)
- [Zod to X](/ecosystem?id=zod-to-x)
- [X to Zod](/ecosystem?id=x-to-zod)
- [Mocking Libraries](/ecosystem?id=mocking-libraries)
- [Powered by Zod](/ecosystem?id=powered-by-zod)
I also contribute to the following projects, which I'd like to highlight:
- [tRPC](https://trpc.io) - End-to-end typesafe APIs, with support for Zod schemas
- [React Hook Form](https://react-hook-form.com) - Hook-based form validation with a [Zod resolver](https://react-hook-form.com/docs/useform#resolver)
- [zshy](https://github.com/colinhacks/zshy) - Originally created as Zod's internal build tool. Bundler-free, batteries-included build tool for TypeScript libraries. Powered by `tsc`.
## Sponsors
Sponsorship at any level is appreciated and encouraged. If you built a paid product using Zod, consider one of the [corporate tiers](https://github.com/sponsors/colinhacks).
### Platinum
<Platinum />
<br/>
### Gold
<Gold />
<br/>
### Silver
<Silver />
<br/>
### Bronze
<Bronze />
<br />