Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-schema-to-zod

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-to-zod

Converts JSON schema objects or files into Zod schemas

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29K
increased by13.43%
Maintainers
1
Weekly downloads
 
Created
Source

Json-Schema-to-Zod

NPM Version

Summary

A very simple CLI tool to convert JSON schema 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

Package last updated on 30 May 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc