Skip to content

Latest commit

 

History

History
52 lines (37 loc) · 1.24 KB

README.md

File metadata and controls

52 lines (37 loc) · 1.24 KB

zod-to-protobuf

NPM Version NPM Downloads

Summary

Convert Zod schemas to Protocol Buffers definitions.

Installation

npm install zod-to-protobuf

Usage

import { z } from 'zod'
import { zodToProtobuf } from 'zod-to-protobuf'

const schema = z.object({
    name: z.string(),
    age: z.number()
})

const proto = zodToProtobuf(schema)
console.log(proto)

Expected Output

syntax = "proto3";
package default;

message Message {
    string name = 1;
    double age = 2;
}

Options

Option Description Default
packageName Name of the protobuf package default
rootMessageName Name of the protobuf message Message
typePrefix Prefix for each type (empty string)

Contributing

Contributions are welcome! Please open an issue or submit a pull request.