BYTETOOLS

JSON to Protobuf Schema Generator

Generate a proto3 .proto message definition from a sample JSON document. Infers int32, int64, double, bool, string, repeated fields and nested messages.

What is the JSON to Protobuf Schema Generator?

The ByteTools JSON to Protobuf Schema Generator writes the first draft of a . proto file for you.

  • Infers int32, int64, double, bool and string from the values
  • Nested objects become nested messages in PascalCase
  • Arrays become repeated fields with a merged element type
  • google.protobuf.Value for null, empty and mixed arrays
  • Optional package declaration and proto3 optional keyword
  • Runs entirely in your browser — the payload is never uploaded

How to use the JSON to Protobuf Schema Generator

  1. 1

    Paste a representative JSON object or array into the input box.

  2. 2

    Set the root message name and, if you want one, a package name.

  3. 3

    Tick 'Mark singular fields optional' if you need proto3 field presence.

  4. 4

    Click Generate .proto to build the schema.

  5. 5

    Copy the definition or download it as schema.proto.

About the JSON to Protobuf Schema Generator

The ByteTools JSON to Protobuf Schema Generator writes the first draft of a .proto file for you. Paste a representative JSON document, click Generate, and you get a proto3 message with snake_case field names, sequential field numbers and a nested message for every nested object.

Types are inferred from the values: strings become string, whole numbers become int32 or int64 depending on magnitude, anything with a fractional part becomes double, and booleans become bool. Arrays become repeated fields whose element type is merged across every element, so an array of objects produces one message rather than many.

Where JSON genuinely has no protobuf equivalent — an empty array, an all-null field, or a mixed-type array — the generator emits google.protobuf.Value and adds the struct.proto import, rather than guessing and giving you a schema that silently loses data. Everything runs in your browser and your sample payload is never uploaded.

Frequently asked questions

How do I create a .proto file from JSON?

Paste a sample payload that includes every field you care about, name the root message and click Generate. The output is a valid proto3 definition you can save as schema.proto and compile with protoc.

When does a number become int64 instead of int32?

When any value in that field falls outside the signed 32-bit range of −2,147,483,648 to 2,147,483,647. A field seen only with small whole numbers is typed int32, and anything with a decimal point becomes double.

Why did a field become google.protobuf.Value?

Because the sample gave no usable type — the value was always null, the array was empty, or the array mixed types such as numbers and strings. Rather than guess, the generator uses the well-known Value type and adds the struct.proto import.

Are the field numbers safe to change?

They are assigned sequentially from 1 as a starting point. Once a schema is deployed, field numbers are part of the wire format and must never be reused for a different field — treat the generated numbers as a draft, not a contract.

Should I use the optional keyword?

Use it when you need to tell an unset field apart from a zero, empty string or false. proto3 reintroduced optional for exactly that, at the cost of a small amount of extra generated code.

Related tools