一覧へ戻る
lucaconlaq/zod-to-code(新しいタブで開きます)
主要言語: TypeScript
Generate JavaScript/TypeScript code from Zod schemas.
- star 数
- 0
- watcher 数
- 1
- fork 数
- 3
- issue 数
- 1
- 最終更新
- 2025/07/15
主要言語: TypeScript
Generate JavaScript/TypeScript code from Zod schemas.
Generate JavaScript/TypeScript code from Zod schemas — round-trip safe 🌀
zod schemas.npm i @lucaconlaq/zod-to-code
import { z } from "zod"; import { zodToCode } from "@lucaconlaq/zod-to-code"; const schema = z.object({ username: z.string(), }); const code = zodToCode(schema); console.log(code);
Outputs:
z.object({ username: z.string() })
| Type | Status |
|---|---|
string |
✅ Supported |
number |
✅ Supported |
boolean |
✅ Supported |
date |
✅ Supported |
bigint |
✅ Supported |
symbol |
✅ Supported |
void |
✅ Supported |
never |
✅ Supported |
unknown |
✅ Supported |
any |
✅ Supported |
object |
✅ Supported |
array |
✅ Supported |
tuple |
✅ Supported |
record |
✅ Supported |
map |
✅ Supported |
set |
✅ Supported |
function |
✅ Supported |
lazy |
✅ Supported |
literal |
✅ Supported |
enum |
✅ Supported |
nativeEnum |
✅ Supported |
union |
✅ Supported |
intersection |
✅ Supported |
or |
✅ Supported |
and |
✅ Supported |
.optional() |
✅ Supported |
.nullable() |
✅ Supported |
.nullish() |
✅ Supported |
.default() |
✅ Supported |
.catch() |
✅ Supported |
.describe() |
✅ Supported |
.readonly() |
✅ Supported |
.brand() |
✅ Supported |
.int() |
✅ Supported |
.email() |
✅ Supported |
.uuid() |
✅ Supported |
.regex() |
✅ Supported |
.url() |
✅ Supported |
.ip() |
✅ Supported |
.datetime() |
✅ Supported |
.emoji() |
✅ Supported |
.refine() |
❌ Not Supported |
.superRefine() |
❌ Not Supported |
.transform() |
❌ Not Supported |
.pipe() |
❌ Not Supported |
z.custom() (e.g. Buffer) |
❌ Not Supported |
| Effects with unsupported type | ❌ Not Supported |
Unknown typeName (mock types) |
❌ Not Supported |
| Non-serializable transforms | ❌ Not Supported |