TrendWhat rose on GitHub, every day at 07:30 KST · 한국어

GitHub · as of November 8, 2026 · View on GitHub →

colinhacks/zod

TypeScript schema validation library

+45 stars in 7 days

Validate untrusted data and infer types automatically

Use this tool when handling data of unknown origin, such as API responses or user input, and you want to verify its shape against predefined rules. Write a schema once, and it validates data at runtime while automatically generating static types for TypeScript. This eliminates the need to write separate code for data validation and type declaration.

Schema definition and type extraction

Describe the type of each object field using methods like z.object. When parsing data with this schema, invalid values are filtered out, and valid values are returned with guaranteed types. The z.infer utility extracts the derived type from the schema without requiring a separate type declaration. If you use transformation logic where input and output types differ, you can independently retrieve each type using z.input and z.output. This structure ensures that data validation logic and the type system always remain consistent.

Improving validation speed with compilation

In paths where data is validated very frequently, use z.compile to improve performance. This method pre-compiles the schema to enhance validation speed, showing a 2.4x speedup in median benchmarks across 55 schemas. It can be up to 9 times faster for high-throughput cases like arrays of objects or objects with many keys, but there is no speed difference for low-throughput tasks like simple string validation. Compiled schemas follow a fast path for valid inputs, but invalid inputs fall back to the existing parser, so error reporting remains the same. However, schemas containing asynchronous refinement or transformation cannot be compiled; in these cases, the existing parser is used as is.

Error handling and installation

If validation fails, a ZodError is thrown, providing detailed information on which field failed and why. If you want to avoid try/catch blocks, use safeParse to receive the success status and data in a single result object. This tool has no external dependencies and works in Node.js and all modern browsers. The compressed core bundle size is 2kb. Installation is done simply by running the npm install zod command, and it can be used in both TypeScript and standard JavaScript projects.

Considerations when using compilation

Enabling z.compile globally uses new Function, so in environments with strict Content Security Policies (CSP), you should set the jitless option or avoid direct compilation calls. Additionally, deriving a new schema from a compiled schema un-compiles it, so it is recommended to compile after defining the final schema. Schemas containing asynchronous logic are excluded from compilation, so if you need these features, design your application assuming the use of the existing parser.

Written by AI from this repository's README on September 27, 2026. For the facts, the original on GitHub is the reference.

By the numbers

GitHub trending history
6 days between Jun 19, when Trend began recording, and Nov 8, 2026 · first on Aug 30 · best daily rank #16 (Aug 30)

Read from GitHub, as of November 8, 2026.

Language
TypeScript
Topics
runtime-validation · schema-validation · static-types · type-inference · typescript
Stars
44,286
Stars gained in 7 days
+45
Contributors
592
Forks
2,328
Latest release
v4.6.7 · October 12, 2026
Commits
3,273
Last commit
November 6, 2026
Open issues
103
Open pull requests
17
Used by
3,020,331

View on GitHub → · Homepage

README badge

trend.ondo.sh · GitHub daily trending #16 · August 30, 2026

The badge above shows the highest this repository has ranked on GitHub's daily trending since June 19, 2026, and the day it did. Paste the Markdown below into your README. The badge opens this page, and it updates by itself when the repository climbs higher.

[![trend.ondo.sh](https://trend.ondo.sh/github/r/colinhacks--zod/badge.en.svg)](https://trend.ondo.sh/github/r/colinhacks--zod/en.html)