Skip to main content

JSON ↔ Protobuf Toolkit

Infer .proto schemas from JSON, or encode and decode Protobuf payloads with your schema

JSON sample

Up to 5 MB.

Options

Field names
Advanced

Generated .proto

No schema yet
Paste a JSON sample or load an example, then choose Generate .proto.

Paste a JSON sample or load an example, then choose Generate .proto.

Three conversions, kept apart

JSON → .proto infers a proto3 schema from a JSON sample. JSON → Protobuf encodes a JSON payload into binary with your own .proto schema and message type, and Protobuf → JSON decodes hex, base64 or a binary file back to JSON. Schema inference and real encoding are different jobs, so each has its own mode.

How schemas are inferred

Strings become string, booleans bool, decimals double and integers int64 by default, because a value that fits int32 today may not tomorrow. Objects become messages named in PascalCase from their keys, arrays of one type become repeated fields, and every object of an array is merged so optional keys are not missed. Null-only, empty or mixed values use google.protobuf.Value and are listed as notes. Field numbers are assigned in key order; once a schema is deployed they are part of the wire format and must not change.

Encoding and decoding

JSON uses the ProtoJSON mapping: lowerCamelCase field names, 64-bit integers as strings, bytes as base64, enums as names and the special forms of well-known types such as Timestamp, Duration, Struct and wrappers. Advanced options can emit default values, keep proto field names, write enums as numbers or ignore unknown JSON fields. Decoding lists field numbers the selected message does not declare, a common sign that the wrong message type is selected.

Limits and privacy

Schemas must be self-contained: Google well-known types (Timestamp, Duration, Struct, Any, Empty, FieldMask and wrappers) are bundled, and other imports are never fetched from the network. A sample cannot reveal enums, maps, presence or evolution plans, so review every inferred schema. Everything runs in your browser; payloads and schemas are not uploaded.

JSON Schema and .proto

JSON Schema → .proto turns objects into messages, string enums into enums with an UNSPECIFIED zero value, additionalProperties into maps, oneOf of objects into oneof and date-time strings into google.protobuf.Timestamp, numbering fields in declaration order and skipping 19000–19999. Validation keywords such as pattern, minimum or if/then are listed in the conversion report because Protobuf cannot express them. .proto → JSON Schema writes Draft 2020-12 with one $defs entry per message and enum and follows the ProtoJSON mapping: 64-bit integers as numeric strings, bytes as base64 and enums as names. The x-protobuf extensions keep field numbers and types, so the schema converts back to the same wire contract.

Frequently asked questions
Is the inferred .proto schema exact?
No. It is a starting point inferred from one sample. A sample cannot show enum intent, maps, presence or how the schema will evolve, so the tool lists every guess as a note and shows a review warning before you copy. Field numbers become part of the wire format once the schema is deployed, so review them before release.
Which JSON format is used for encoding and decoding?
The ProtoJSON mapping: lowerCamelCase field names (proto names are also accepted on input), 64-bit integers as strings, bytes as base64, enums as names and the special forms of well-known types such as Timestamp and Struct. Advanced options can emit default values, keep proto field names, write enums as numbers or ignore unknown JSON fields.
Are my schemas and payloads uploaded?
No. Inference, encoding and decoding run in your browser. Imports other than the bundled Google well-known types are not fetched, so paste imported definitions into the schema instead.

CodingTool is officially live on