Home

Awesome

Json-to-Zod

Summary

A very simple CLI tool to convert JSON objects or files into zod schemas.

Usage

CLI

json-to-zod -s myJson.json -t mySchema.ts

Options:

Programmatic

import { jsonToZod } from "json-to-zod"

const myObject = {
    hello: "hi"
}

const result = jsonToZod(myObject)

console.log(result)

Expected output:

const schema = z.object({hello: z.string()});