Home → JSON to Protobuf Schema Generator

JSON to Protobuf Schema Generator

Convert JSON to Protocol Buffer schema definitions for gRPC systems.

About This Tool

Convert JSON to Protocol Buffer schema definitions for gRPC systems. This tool runs entirely in your browser — no data is ever sent to a server. Free to use, no account required.

What Protocol Buffers (Protobuf) Are

Protobuf is Google's binary serialization format — faster and more compact than JSON, but requiring a schema to encode and decode data.

Protobuf Schema (.proto files)

A .proto file defines messages with named, typed, numbered fields. Each field has a type (string, int32, bool, bytes, or another message type) and a unique field number. The schema is compiled by protoc to generate serialization code in your language of choice.

Protobuf vs JSON

Protobuf is 3–10x smaller than equivalent JSON because field names are replaced by field numbers in the binary encoding, and data types are encoded more efficiently. Parse speed is also 5–10x faster, making Protobuf standard for high-performance internal microservice APIs.

Converting JSON to Protobuf Schema

The tool generates a .proto file from your JSON sample, mapping JSON types to appropriate Protobuf field types.

Field Type Mapping

JSON string → string, integer → int32 or int64, float → float or double, boolean → bool, nested object → message, array → repeated field. The tool chooses int32 vs int64 and float vs double based on the magnitude of values in your sample.

Field Numbers

Protobuf requires a unique integer field number per field, used in the binary encoding. The tool assigns numbers sequentially starting from 1. Field numbers 1–15 are most efficient and should be used for the most frequent fields.

Frequently Asked Questions

What is Protocol Buffers (Protobuf)?+
Protocol Buffers (Protobuf) is a language-agnostic binary serialization format developed by Google. Data is encoded according to a .proto schema file that defines message types and field types. Protobuf is 3–10x smaller and 5–10x faster to parse than JSON, making it the preferred choice for internal APIs, gRPC services, and performance-critical microservices.
Why convert JSON to Protobuf?+
If you have existing JSON data and want to migrate to Protobuf for better performance, you need a .proto schema that mirrors your JSON structure. Converting JSON to Protobuf schema saves the time of writing the .proto file by hand. Once you have the schema, use protoc to generate serialization code in Go, Python, Java, C++, and many other languages.
What is a Protobuf field number?+
Every field in a Protobuf message has a unique integer tag called a field number (e.g., string name = 1;). Field numbers are embedded in the binary encoding and must never change once the schema is in production — changing a field number is a breaking change. Field numbers 1–15 use one byte in encoding and should be used for the most frequent fields.
Can Protobuf replace JSON in REST APIs?+
Protobuf is most commonly used with gRPC. You can use Protobuf with REST HTTP/1.1 (with Content-Type: application/protobuf), but most REST clients and browsers expect JSON. A common pattern is Protobuf for internal service-to-service calls and JSON for external APIs and browser clients.

JSON to Protobuf Conversion Guide

Protocol Buffers (Protobuf) is Google's binary serialization format — 3-10x smaller and 5-10x faster than JSON. It's the standard format for gRPC APIs and high-performance microservices.

JSON Input → Proto3 Definition

// JSON
{"userId": 1, "name": "Alice", "email": "alice@example.com", "active": true, "score": 98.5}

// Proto3 Definition
syntax = "proto3";

package example;

message User {
  int32  user_id = 1;
  string name    = 2;
  string email   = 3;
  bool   active  = 4;
  double score   = 5;
}

JSON vs Protobuf Size Comparison

DatasetJSON SizeProtobuf SizeSavings
1,000 user records~80 KB~18 KB78% smaller
1M event log records~200 MB~45 MB78% smaller
Parse speed (1M records)~2.1s~0.3s7x faster

JSON to Protobuf Type Mappings

JSON TypeProto3 TypeNotes
stringstring
integer (small)int32
integer (large)int64
float (32-bit)float
float (64-bit)double
booleanbool
arrayrepeated Type
nested objectmessageDefine separate message
nullableoptional TypeProto3 optional keyword

Explore more tools: All JSON Tools | Validator | Pretty Print | JSON Diff

JSON to Protobuf Type Mapping

Every JSON value type maps to one or more Protobuf scalar or composite types. Choosing the right type matters: using int32 for a Unix timestamp that exceeds 2,147,483,647 will silently truncate data. Always use int64 for epoch milliseconds, IDs, and any number that may grow large.

JSON Type Protobuf Type Notes
stringstringDirect mapping
integerint32 / int64Use int64 for large numbers
floatfloat / doubleUse double for precision
booleanboolDirect mapping
nulloptional / oneofNo direct null in proto3
arrayrepeatedrepeated string tags = 4;
objectmessageNested message definition

Generated .proto Example

Given the JSON input {"name":"Alice","age":30,"email":"alice@example.com","active":true}, the converter produces:

syntax = "proto3";
package example;

message User {
  string name   = 1;
  int32  age    = 2;
  string email  = 3;
  bool   active = 4;
}

Protobuf vs JSON: Performance Comparison

Protobuf is a binary encoding format designed for high-throughput, low-latency scenarios such as gRPC services, Kafka message queues, and mobile apps with limited bandwidth. JSON prioritizes human readability and universal tooling support. Use JSON for public APIs and configuration files; use Protobuf when performance or payload size is the bottleneck.

Aspect JSON Protobuf
Human readableYesNo (binary)
File sizeBaseline3–10x smaller
Parse speedBaseline5–10x faster
Schema requiredNoYes (.proto file)
Language supportUniversalMost major languages
DebuggingEasy (text)Harder (needs schema)
Best forWeb APIs, configsgRPC, Kafka, high-performance systems