Monitoring
Solutions
Resources
Free Tools
Pricing
Free Tools / Converters / JSON to Protobuf Generator

JSON to Protobuf Generator

Paste a JSON payload and get a proto3 definition for it: a message per object, repeated fields for arrays, scalar types inferred from the values and field numbers assigned in order.

Runs entirely in your browser — nothing you enter here is sent to a server.

From JSON to a Protocol Buffers schema

JSON carries its field names in every message and has no schema. Protocol Buffers work the other way round: you define the structure once in a .proto file, and messages on the wire contain only field numbers and compact binary values. Moving an API from REST and JSON to gRPC starts with writing that definition — and for an existing payload, most of it can be derived.

Messages

The root object becomes a message, and each nested object a message declared inside it, named after its key.

Scalar types

string, bool, int32 (int64 for large values) and double. A null value has no type and becomes google.protobuf.Value.

Arrays

Become repeated fields. For arrays of objects, the fields of all elements are merged, and those missing from some are marked optional.

Names and numbers

Field names are converted to snake_case, as the style guide asks; proto3's JSON mapping turns them back into camelCase. Numbers start at 1 in key order.

What to decide yourself

A sample gives the shape, not the intent. Before the schema is used by anyone, look at the choices a generator cannot make. Should an id be int64, or a string to be safe in JavaScript clients? Is a timestamp string better as google.protobuf.Timestamp? Is a string with a few possible values really an enum? Should money be integer minor units rather than double?

Then treat the field numbers as permanent. They identify fields on the wire: once clients exist, never change a number or reuse one from a deleted field — mark it reserved instead. Numbers 1 to 15 take a single byte, so keep them for the fields sent most often.

Frequently asked questions

What is a .proto file?

The schema for Protocol Buffers: a text file that defines messages and their typed, numbered fields. The protoc compiler generates code for many languages from it.

Why are the field names in snake_case?

It is the convention of the Protobuf style guide. The standard JSON mapping converts snake_case field names to lowerCamelCase automatically, so your JSON keeps its original key names.

Does the order of fields matter?

Not the order in the file, but the numbers do. Fields are identified on the wire by number, so numbers must never be changed or reused once a schema is in use.

Can it generate proto2?

The output is proto3, the current default. For proto2, change the syntax line and add "optional" or "required" labels to the fields.

Related free tools

A calculator answers once. Monitoring answers every minute.

Upzilla checks your sites, servers and APIs around the clock and alerts you the moment something breaks. 10 monitors free, no card required.

Start monitoring free →