PureDevTools

JSON Schema to Protobuf Converter

Convert JSON Schema to proto3 message definitions — types, nested messages, enums, repeated fields

All processing happens in your browser. No data is sent to any server.

Options

993 characters

3 messages + 1 enum generated · 531 characters

Messages: 3Enums: 1Syntax: proto3Package: mypackage

You have a JSON Schema defining your data model, and now you need Protocol Buffer definitions for gRPC services or efficient binary serialization. Manually translating JSON Schema types to proto3 message fields — mapping strings, numbers, booleans, nested objects, and arrays to their protobuf equivalents — is tedious and error-prone.

What Are Protocol Buffers?

Protocol Buffers (protobuf) is Google’s language-neutral, platform-neutral serialization format. Unlike JSON, protobuf uses a binary wire format that is smaller and faster to parse. Proto definitions (.proto files) describe message structures that are compiled into code for Go, Java, Python, C++, TypeScript, and other languages. Protobuf is the standard serialization format for gRPC.

How This Converter Works

Paste a valid JSON Schema and the tool generates proto3 message definitions:

  1. Primitive type mapping: stringstring, numberdouble, integerint32, booleanbool
  2. Objects: type: "object" with properties becomes a message with numbered fields
  3. Arrays: type: "array" with items becomes repeated fields
  4. Nested objects: Inline object schemas become nested message definitions
  5. Enums: enum arrays of strings become proto enum types
  6. Optional fields: Properties not in required use the optional keyword (proto3)
  7. $ref resolution: Internal references are resolved and generate separate named messages

Common Use Cases

REST to gRPC migration — Convert your existing JSON Schema API contracts to protobuf definitions when migrating from REST/JSON to gRPC.

Polyglot services — Generate proto definitions from your JSON Schema, then compile to Go, Java, Python, or TypeScript for consistent data structures across microservices.

Performance optimization — Replace JSON serialization with protobuf for internal service communication where payload size and parsing speed matter.

Schema evolution — Use protobuf’s built-in backward compatibility (field numbers) alongside your existing JSON Schema versioning strategy.

Proto3 Type Mapping Reference

JSON SchemaProto3 Type
stringstring
numberdouble
integerint32
booleanbool
objectmessage
arrayrepeated
nullgoogle.protobuf.NullValue

Frequently Asked Questions

Q: Which protobuf syntax version is generated? A: The tool generates proto3 syntax, which is the current and recommended version. Proto3 has simpler semantics — all fields are optional by default, and the optional keyword explicitly marks presence tracking.

Q: How are nested JSON Schema objects handled? A: Each nested object becomes a nested message definition inside the parent message. Deeply nested structures produce correspondingly nested messages.

Q: What happens to JSON Schema $ref references? A: Internal $ref references are resolved and generate top-level message definitions. The referencing field uses the message name as its type.

Q: Are field numbers assigned automatically? A: Yes. Fields are numbered sequentially starting from 1 in declaration order. After generating, you should review and stabilize field numbers before using them in production, since changing numbers breaks backward compatibility.

Q: Is my schema sent to a server? A: No. All conversion runs in your browser using JavaScript. Your JSON Schema never leaves your device.

Related Tools

More Code Transforms