JSON to Protobuf message (proto3)
A starting point for defining a gRPC service or moving existing JSON data to Protobuf.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Enter json input and root type name.
- The result appears straight away and updates as you edit.
- Copy the result, or copy a link that keeps the same values to share it.
How it is calculated
string, int32 or int64, double and bool, repeated for arrays, and a message per object with field numbers from 1 in key order. Names are snake_case with json_name when the derived name differs from the key, and null on a scalar adds optional. Mixed values use google.protobuf.Value.
Example
Inputs: Root type name = Root. Result: Generated code: syntax = "proto3"; message Root { int32 id = 1; string name = 2; string email = 3; bool is_active = 4 [json_name = "is_active"]; double balance = 5; repeated string tags = 6; Address address = 7; repeated Order orders = 8; } message Address { string city = 1; string postal_code = 2 [json_name = "postal_code"]; } message Order { string order_id = 1 [json_name = "order_id"]; double total = 2; optional string coupon = 3; }; Types generated: 3; Fields: 13.
{
"id": 1024,
"name": "Sara Ahmed",
"email": "sara@example.com",
"is_active": true,
"balance": 1520.75,
"tags": ["vip", "riyadh"],
"address": { "city": "Riyadh", "postal_code": "12211" },
"orders": [
{ "order_id": "A-1", "total": 99.5, "coupon": "EID10" },
{ "order_id": "A-2", "total": 120, "coupon": null }
]
}syntax = "proto3";
message Root {
int32 id = 1;
string name = 2;
string email = 3;
bool is_active = 4 [json_name = "is_active"];
double balance = 5;
repeated string tags = 6;
Address address = 7;
repeated Order orders = 8;
}
message Address {
string city = 1;
string postal_code = 2 [json_name = "postal_code"];
}
message Order {
string order_id = 1 [json_name = "order_id"];
double total = 2;
optional string coupon = 3;
}Limits and caveats
- In the official Protobuf JSON mapping, int64 is printed as a quoted string.
- Field numbers follow key order; do not change them once messages are in production.
Questions about this tool
When is json_name added?
Protobuf derives the JSON name by turning snake_case into camelCase; when that differs from the original key, json_name is added.
Why int32 and not int64?
int32 is used while values fit, and int64 when a number above 2147483647 appears.
Is my JSON sent to a server?
No. The conversion runs in your browser and the JSON never leaves your device.
