JSON to Protobuf Schema
Generate a Protocol Buffers schema (proto3) from a JSON sample. Nested objects become their own messages, arrays become repeated fields, and fields are numbered in the order they appear in the sample. Whole numbers become int64 and decimals become double.
JSON
Protocol Buffers
Result will appear hereReady. Press Generate or Ctrl+Enter.
How to use the JSON to Protobuf Schema
- Paste a JSON sample in the left pane.
- Set the proto package and the root message name.
- Press Generate, then copy the schema or download it as a .proto file.
Example
Field numbers follow the order of the keys in the sample.
{
"name": "json-utils",
"version": "1.0.0",
"private": false,
"tags": ["json", "tools"],
"author": { "name": "Ada", "active": true },
"score": 9.5,
"notes": null
}Frequently asked questions
What happens to null values?
proto3 has no null, so a field that is null in the sample becomes a string field with a comment saying the type is a guess. Check those fields against your real payloads.
How are field numbers assigned?
Sequentially, in the order fields appear in the sample, starting at 1 in each message. Renumber before publishing if your API already has conventions.