Zod

TypeScript-first schema validation with static type inference and zero dependencies.

Library
npm
v4.6.5
44,052 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
92 /100 Excellent
Development Activity 100
Maintenance 100
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
89 /100 Excellent
Architecture 90
Code Quality 90
Innovation 92
Learning Curve 85

Zod is a TypeScript-first schema declaration and validation library. You define a schema once, and Zod both validates untrusted data against it at runtime and infers a precise static TypeScript type from it, so the type system and the runtime check can never drift apart. It ships with zero external dependencies, a roughly 2kb gzipped core bundle, and works identically in Node.js, Deno, Bun, and every modern browser.

Beyond primitive and object schemas, Zod supports unions, discriminated unions, recursive types, refinements, transforms, and built-in JSON Schema conversion, and its .safeParse() API returns a typed result object instead of throwing, making error handling explicit. It has become the de facto standard for runtime validation in the TypeScript ecosystem, with first-class integrations across tRPC, React Hook Form, Next.js Server Actions, and dozens of other frameworks.

What You Get

  • A fluent, chainable schema-builder API covering primitives, objects, arrays, unions, discriminated unions, tuples, records, maps, sets, and recursive types
  • Automatic static type inference (z.infer, z.input, z.output) so schemas double as your TypeScript types
  • .parse() / .safeParse() (and async variants) for throwing or non-throwing validation with a structured ZodError and granular issue list
  • Built-in transforms and refinements (.transform(), .refine(), .superRefine()) for coercion and cross-field validation logic
  • Native JSON Schema generation (z.toJSONSchema()) and Standard Schema interop for tooling that speaks a common validation contract
  • A zod/mini build with a functional, tree-shakeable API for bundle-size-sensitive projects

Common Use Cases

  • Validating and typing incoming API request bodies and query parameters in an Express, Fastify, Next.js, or Hono route handler
  • Defining end-to-end typesafe contracts in tRPC procedures or Server Actions without hand-written DTOs
  • Validating environment variables at process startup so misconfiguration fails fast with a readable error
  • Powering form validation and typed form state in React Hook Form, Formik, or Conform integrations
  • Parsing and normalizing third-party API responses at the network boundary before they enter application code

Under The Hood

Architecture — Zod’s source (packages/zod/src) is split into a v4/core layer (schema traits, parsing engine, error formatting, JSON Schema conversion, in core.ts, parse.ts, schemas.ts) and a v4/classic layer that layers the familiar chainable z.object()-style API on top of it. A parallel v3 tree preserves the legacy API verbatim for backward compatibility, and v4-mini/mini expose a functional, tree-shakeable variant of the same core. Schema classes are built with a custom $constructor trait system (core.ts) rather than plain ES classes, which lets one definition be shared across the classic, mini, and JSON Schema surfaces without duplicating parsing logic — a deliberate structural choice to support three public API shapes from one validation core.

Tech Stack — Pure TypeScript (~89% of the repo by bytes) with zero runtime dependencies, targeting Node.js, Deno, Bun, and browsers via dual ESM/CJS output built with zshy/tsdown. The repo is a pnpm workspace (packages/zod, packages/docs, packages/bench, packages/integration) with Biome handling linting and formatting and Vitest running the test suite; a check:semver pre-commit hook enforces that version numbers stay in sync across package.json, jsr.json, and the in-source versions.ts.

Code Quality — The v4/core and v4/classic trees each carry their own tests/ directories (168+ test files repo-wide) covering primitive types, refinements, error formatting, and JSON Schema conversion, and AGENTS.md codifies house rules enforced in review: every feature or fix needs a test, no console.log/debugger in shipped code, and tests must stay dense rather than padded with redundant assertions. Error handling is explicit throughout — .safeParse() returns a discriminated-union result rather than relying on exceptions for control flow, and ZodError carries a structured, machine-readable issues array.

API Design — The chainable builder API (z.string().min(3).email()) reads close to prose, and .safeParse()/.parse() give callers a choice between exception-based and result-based error handling depending on context. Getting started requires no boilerplate beyond import * as z from "zod" and one schema declaration — the inferred type is available immediately via z.infer<typeof Schema> with no code generation step. Naming is consistent across the whole surface (.min/.max/.optional/.nullable behave the same on every schema type), and the package even publishes an llms.txt/llms-full.txt and an MCP server specifically to make its API legible to AI coding tools.

Used by 277 apps in this directory

Ruby
62%
MIT

OnetimeSecret

Security

2,947

Generate self-destructing single-use links to share passwords and sensitive data without leaving traces in inboxes or chat logs.

View details
92
Repo Health
81
Technical
72
Dependency
Built with
Ruby 62%
TypeScript 25%
Updated 1 weeks ago
TypeScript
95%
Apache 2.0

OneUptime

Monitoring

7,668

The complete open-source observability platform that replaces PagerDuty, Datadog, Sentry, and StatusPage with a single self-hostable system.

View details
91
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 95%
Updated 1 weeks ago
TypeScript
99%
Apache 2.0

Onlook

AI Design Tools · Design Tools

26,820

An open-source, AI-first visual editor that lets designers and developers build, style, and deploy React apps directly in code — no handoff required.

View details
65
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 99%
Updated 1 months ago
TypeScript
99%
MIT

open-agents

AI Agents · Developer Tools

5,829

Open-source reference app for building and running background AI coding agents on Vercel — from chat prompt to committed code changes without keeping your laptop involved.

View details
43
Repo Health
78
Technical
73
Dependency
Built with
TypeScript 99%
Updated 1 months ago
TypeScript
71%
Apache 2.0

open-design

Design Tools

98,365

Local-first, open-source Claude Design alternative that turns your existing coding agent CLI into a full agentic design studio — with 259+ skills, 142+ design systems, and sandboxed artifact delivery across web, desktop, and mobile surfaces.

View details
85
Repo Health
86
Technical
72
Dependency
Built with
TypeScript 71%
HTML 22%
Updated 1 weeks ago
TypeScript
97%
GPL 3.0

OpenKnowledge

Code Editors · Knowledge Management · Note Taking

4,337

A beautiful, local-first markdown IDE that turns any git repo into a live collaborative workspace for humans and AI coding agents like Claude, Codex, and OpenCode.

View details
79
Repo Health
89
Technical
64
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
TypeScript
95%
MIT

Open Lovable

AI Development

28,602

An open-source AI app builder that scrapes a live website and recreates it as a modern React app through chat — built by Firecrawl as a self-hostable example of the Lovable.dev workflow.

View details
35
Repo Health
66
Technical
70
Dependency
Built with
TypeScript 95%
Updated 10 months ago
TypeScript
58%
MIT

open-notebook

AI Assistants · Note Taking

39,569

A privacy-first, self-hosted AI research notebook with 18+ model providers, multi-speaker podcast generation, and full REST API—your open-source alternative to Google Notebook LM.

View details
90
Repo Health
84
Technical
71
Dependency
Built with
TypeScript 58%
Python 39%
Updated 1 weeks ago
TypeScript
90%
MIT

open-pencil

AI Design Tools · Design Tools

8,642

An open-source design editor that reads native Figma files, ships a built-in AI assistant with 100+ design tools, and offers real-time serverless collaboration — all without giving up your files.

View details
81
Repo Health
78
Technical
69
Dependency
Built with
TypeScript 90%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers