Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

JSON to Protobuf Schema Converter

Paste JSON and instantly generate Protocol Buffer (.proto) message definitions with nested messages and repeated fields

Your files never leave your browser
Input (JSON)0 chars, 0 lines
Output (.proto)0 chars, 0 lines
Ready·

Paste any JSON object and get a valid .proto schema back — field numbers assigned, types inferred, nested messages split into their own blocks. Supports proto2 and proto3 syntax, custom root names, and package declarations. And everything runs in your browser. Nothing gets uploaded.

How It Works

Paste JSON
➔
Analyze Types & Nesting
➔
Output .proto Schema

The parser walks your JSON tree from top to bottom. Strings become string, small integers become int32, large ones int64, decimals become double, and booleans map to bool. When it hits a nested object, it creates a new message definition and references it by name. Arrays turn into repeated fields. Field numbers get assigned in order, starting at 1 for each message.

Examples

Simple User Object

A basic user profile from a REST API response.

INPUT
{ "id": 42, "name": "Sara Chen", "email": "[email protected]", "active": true }
OUTPUT
syntax = "proto3"; message Root { int32 id = 1; string name = 2; string email = 3; bool active = 4; }

Nested Order with Line Items

An e-commerce order with an array of products — the kind of structure that’s tedious to convert by hand because each nested object needs its own message block.

INPUT
{ "order_id": 90871, "total": 59.97, "items": [ { "sku": "TEE-BLK-M", "qty": 3, "price": 19.99 } ] }
OUTPUT
syntax = "proto3"; message Items { string sku = 1; int32 qty = 2; double price = 3; } message Root { int32 order_id = 1; double total = 2; repeated Items items = 3; }

Config with Deep Nesting

App config JSON with objects inside objects. Good test of how the converter handles multi-level depth.

INPUT
{ "app": "tracker", "db": { "host": "10.0.0.5", "port": 5432 } }
OUTPUT
syntax = "proto3"; message Db { string host = 1; int32 port = 2; } message Root { string app = 1; Db db = 2; }

Who Uses This

👨‍💻 Backend Developers

Migrating REST APIs from JSON to gRPC — need .proto files that match existing response shapes.

🛠️ DevOps Engineers

Generating schemas for Kafka or Pub/Sub pipelines where Protobuf encoding cuts message size by 60-80%.

🎓 Students

Learning Protobuf syntax by comparing familiar JSON structures to the generated .proto output side by side.

📊 Data Engineers

Creating schema definitions for BigQuery, Spark, or Flink jobs that read Protobuf-encoded data.

Common Mistakes

Pasting invalid JSON

Trailing commas, single quotes, or unquoted keys will break the parser. If you’re copying from a JavaScript file, remember that JS objects aren’t valid JSON. Run it through a JSON validator first or strip the trailing commas.

Expecting enums from string values

A field like "status": "active" maps to string, not a Protobuf enum. The converter can’t guess your enum values from a single JSON sample. You’ll need to manually convert known string sets into enum definitions after generating.

Assuming null means optional

In proto3, all fields are optional by default — there is no required keyword. A JSON null value gets mapped to string with a comment noting it was null. If the field should be a different type, check another sample of your data that has an actual value.

Technical Details

Frequently Asked Questions

How do JSON types map to Protobuf types?

Strings become string, booleans become bool, and decimals become double. Integers get int32 if they fit in 32 bits, or int64 for larger numbers. Nested objects become separate message definitions, and arrays become repeated fields.

What’s the difference between proto2 and proto3?

Proto3 dropped the required and optional keywords — every field is optional by default. It also removed custom default values and added built-in JSON mapping. Proto2 still uses explicit labels. For new projects, proto3 is almost always the right pick.

Can I convert deeply nested JSON?

Yes. The converter walks every level of nesting recursively. Each nested object gets its own named message definition, and the parent references it. There is no depth limit beyond what your browser can handle.

Is my JSON data sent to a server?

No. The entire conversion happens in JavaScript inside your browser. Nothing is uploaded, transmitted, or logged. You can verify by opening DevTools and watching the Network tab — zero requests go out. The tool even works offline.

How do arrays get handled in the output?

Arrays become repeated fields. The converter looks at the first element to determine the type. An array of strings gives you repeated string, an array of objects creates a new message type and marks the field as repeated MessageName. Empty arrays default to repeated string since there’s nothing to infer from.

Share: