JSON to Protobuf Schema

JSON Tools

How to use the JSON to Protobuf Schema

Generate Protobuf schema from JSON:

1

Paste your JSON

Paste a JSON object representing the message structure. Arrays of objects are also accepted — the first element is used for field inference.

2

Set message name

Enter the Protobuf message name in PascalCase by convention (e.g. User, CreateOrderRequest). Nested objects automatically generate their own named message definitions.

3

Click Generate

Get a complete proto3 file with syntax declaration, package, and message definitions. Field names are converted to snake_case per proto3 conventions, with sequential field numbers starting at 1.

4

Review and refine

Copy into your .proto file and add service definitions, rpc methods, enums, and oneof fields as needed. Replace string timestamp fields with google.protobuf.Timestamp for production use.


When to use this tool

Use this when migrating from REST/JSON to gRPC or Protocol Buffers:

  • Starting a gRPC service and need .proto message definitions from existing JSON API shapes
  • Migrating a REST API to gRPC and need to define Protobuf messages from current JSON contracts
  • Documenting an API with Protobuf schema for cross-language service communication
  • Learning Protobuf and wanting to see how your existing JSON maps to proto3 syntax
  • Scaffolding .proto files for use with protoc code generation in Go, Java, Python, or C++

Frequently asked questions

Q:What proto version is generated?
The tool generates proto3 syntax (syntax = "proto3"), which is the current standard and required for gRPC. Proto3 removes required fields, defaults all scalar fields to their zero values, and is the version supported by all modern Protobuf tooling.
Q:How are JSON types mapped to proto3 types?
Strings become string, positive integers become uint64, negative integers become sint64, floats become double, booleans become bool, arrays become repeated fields, null values become optional string, and nested objects become separate named message types. Field names are converted from camelCase or PascalCase to snake_case to follow proto3 naming conventions.
Q:Are the field numbers correct?
Field numbers are assigned sequentially starting from 1. In production, never change or reuse field numbers once your schema is deployed — proto3 uses field numbers (not names) for binary encoding, so reordering or reusing numbers would silently corrupt data for existing clients.
Q:How are nested objects and arrays handled?
Nested JSON objects generate separate message definitions that appear above the root message in the output. JSON arrays become repeated fields — arrays of primitives become repeated string or repeated uint64, and arrays of objects generate a named nested message and use repeated NestedMessage as the field type.
Q:How do I handle timestamp fields in proto3?
The generator maps ISO date strings to string as a safe default. For production use, replace these with google.protobuf.Timestamp and add import "google/protobuf/timestamp.proto" at the top of your .proto file. The info banner below the output reminds you of this substitution.
Q:Can I use the output with protoc to generate code?
Yes — the generated .proto file is valid proto3 syntax and works with protoc, the official Protocol Buffer compiler. Run protoc --<language>_out=. your_schema.proto to generate client and server code in Go, Java, Python, C++, C#, Ruby, and other supported languages.