rsinohara / json-to-zod

Converts JSON objects or file to simple Zod schemas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  • --source/-s [source file name]
  • --target/-t [(optional) target file name]
  • --name/-n [(optional) schema name in output]

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()});

About

Converts JSON objects or file to simple Zod schemas

License:ISC License


Languages

Language:JavaScript 57.7%Language:TypeScript 42.3%