DevTools Logo

JSON to Protobuf Converter

JSON to Protobuf Converter

Infer a proto3 schema (.proto) from a JSON sample — fields, types, and nested messages.

JSON sample

client-side
proto3
no network

Types are inferred from values: string, int32/double, bool, nested objects become nested messages, and arrays become repeated fields. Field names are snake_cased and numbered. Null or empty arrays produce a best-effort guess with a warning — review and tighten the schema before shipping.

Examples

A user record

Input
{ "id": 1, "name": "Ada", "active": true, "tags": ["x"] }
Output
message User {
  int32 id = 1;
  string name = 2;
  bool active = 3;
  repeated string tags = 4;
}

Scalar types are inferred from values, the array becomes a repeated field, and fields are numbered in source order.

About this tool

The JSON to Protobuf Converter reads a JSON object and writes the matching proto3 schema. Each key becomes a numbered field whose type is inferred from its value — strings stay string, integers become int32, decimals become double, booleans become bool. Nested objects become nested messages and arrays become repeated fields.

Field names are snake_cased and message names are PascalCased to follow the protobuf style guide. The tool runs in your browser and never uploads your sample. Null values and empty arrays produce a best-effort guess with a warning, so review the schema before shipping.

How to use

  1. Paste a JSON sample

    Use an object that represents one record of your data; the richer the sample, the better the inference.

  2. Name the root message

    Set the root message name (e.g. User) so the generated .proto reads cleanly.

  3. Copy the .proto

    Copy the output and tighten any warnings (nulls, empty arrays, large integers) by hand.

Use cases

Bootstrapping a gRPC schema

Turn one JSON record into a starter .proto file, then refine the types in your editor.

Documenting a JSON API

Express a sample payload as a typed schema for sharing with backend or mobile teams.

Common mistakes

Mistake:Inferring int32 for very large ids.

Fix:Protobuf int32 tops out around 2.1 billion — switch large identifiers to int64 manually.

Mistake:Trusting empty-array inference.

Fix:An empty array is guessed as repeated string; supply a sample element or set the type yourself.

Frequently asked questions

References & standards