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
Paste a representative JSON object or array into the input box.
- 2
Set the root message name and, if you want one, a package name.
- 3
Tick 'Mark singular fields optional' if you need proto3 field presence.
- 4
Click Generate .proto to build the schema.
- 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
JSON to TypeScript
Generate TypeScript interfaces from a JSON sample online. Infers types recursively, merges array shapes and marks optional keys — 100% in your browser.
JSON Formatter
Format, beautify and minify JSON online with 2-space, 4-space or tab indentation. Sort keys alphabetically and catch syntax errors instantly — free and private.
HTML Table to JSON Converter
Turn an HTML table into a JSON array of objects online. Header keys, camelCase or snake_case, number and boolean coercion, NDJSON output — all in-browser.
CSV to JSON Converter
Convert CSV to a JSON array of objects online. Header-row detection, comma/semicolon/tab delimiters and pretty-printed output — 100% in your browser.
JSON Validator
Free online JSON validator: validate JSON and find syntax errors with the exact line and column. See root type, key counts and depth — instant and 100% private.