https://github.com/pykeio/zod-compiler
Speed up your Zod schemas / export TypeScript definitions
https://github.com/pykeio/zod-compiler
Last synced: 11 months ago
JSON representation
Speed up your Zod schemas / export TypeScript definitions
- Host: GitHub
- URL: https://github.com/pykeio/zod-compiler
- Owner: pykeio
- License: apache-2.0
- Created: 2025-04-02T05:36:07.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-23T14:42:21.000Z (about 1 year ago)
- Last Synced: 2025-07-19T13:18:51.022Z (11 months ago)
- Language: TypeScript
- Homepage: https://npmjs.com/package/zod-compiler
- Size: 73.2 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
⚡ zod-compiler ⚡
### Speed up your Zod schemas
```ts
import z from 'zod';
const schema = z.object({
title: z.string().min(3).max(64),
tags: z.array(z.string()).optional(),
...
});
// ❌ slow!
const { success, data, error } = schema.safeParse(input);
// 🚀
import zc from 'zod-compiler';
const compiledSchema = zc.compile(schema);
const { success, data, error } = compiledSchema.safeParse(input);
```
### Export your Zod schemas to TypeScript types
```ts
console.log(zc.types(schema));
// export type Schema = {
// title: string;
// tags?: string[];
// ...
// };
```
## Installation
```shell
$ npm i --save zod-compiler
```
Requires **Zod 3.x** and **TypeScript 5.x** to be installed.