Socket
Socket
Sign inDemoInstall

@lowcode-modou/json-schema-to-zod

Package Overview
Dependencies
9
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @lowcode-modou/json-schema-to-zod

Converts JSON schema objects or files into Zod schemas


Version published
Maintainers
1
Created

Readme

Source

Json-Schema-to-Zod

NPM Version

Summary

A very simple CLI tool to convert JSON schema (draft 4+) objects or files into Zod schemas. Uses Prettier for formatting for now.

Usage

Online

Paste your schemas here

CLI

json-schema-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]
  • --deref/-d [(optional) deref schemas before parsing]

Programmatic

import { jsonSchemaToZod } from "json-schema-to-zod";

const myObject = {
  type: "object",
  properties: {
    hello: {
      type: "string",
    },
  },
};

const result = jsonSchemaToZod(myObject);

console.log(result);

Expected output:

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

Keywords

FAQs

Last updated on 13 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc