JSON to Protobuf Converter

Transform JSON data into Protocol Buffers schema

JSON Input

Protobuf Output

About JSON to Protobuf Converter

Convert JSON data to Protocol Buffers (Protobuf) schema definition. Protocol Buffers is Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.

Key Features

  • Schema Generation: Automatically generates .proto schema from JSON structure
  • Type Inference: Intelligently infers Protobuf types (int32, double, bool, string, repeated)
  • Nested Support: Handles nested objects and arrays with message definitions
  • Proto2 & Proto3: Support for both Protocol Buffers versions
  • Customizable: Configure message name and package name
  • File Upload: Upload JSON files directly or paste data
  • Instant Preview: Real-time conversion as you type

How to Use

  1. Input JSON Data: Paste your JSON data or upload a .json file
  2. Configure Options: Select proto version, message name, and package
  3. Review Output: The Protobuf schema updates automatically
  4. Copy or Download: Use the Copy or Download button to save your .proto file

Example Conversion

JSON Input:

{
  "id": 12345,
  "name": "John Doe",
  "email": "john@example.com",
  "age": 28,
  "active": true,
  "roles": ["admin", "user"]
}

Protobuf Output:

syntax = "proto3";

package com.example;

message Message {
  int32 id = 1;
  string name = 2;
  string email = 3;
  int32 age = 4;
  bool active = 5;
  repeated string roles = 6;
}

Common Use Cases

  • API Design: Generate Protobuf schemas for gRPC services
  • Data Serialization: Convert JSON APIs to efficient binary format
  • Microservices: Define service contracts and data structures
  • Schema Evolution: Create versioned data schemas
  • Cross-Platform: Generate code for multiple languages (Go, Java, Python, C++)

Protobuf Type Mapping

  • String: JSON strings → string
  • Integer: JSON integers → int32 or sint32
  • Float: JSON decimals → double
  • Boolean: JSON booleans → bool
  • Array: JSON arrays → repeated type
  • Object: JSON objects → nested message

Proto2 vs Proto3

  • Proto2: Uses optional/required/repeated keywords, supports default values
  • Proto3: Simpler syntax, all fields are optional by default, no required keyword
  • Recommendation: Use proto3 for new projects (default)

Compiling Protobuf

After generating your .proto file, compile it using the Protocol Buffers compiler:

# For Go
protoc --go_out=. message.proto

# For Java
protoc --java_out=. message.proto

# For Python
protoc --python_out=. message.proto

# For C++
protoc --cpp_out=. message.proto

Privacy & Security

All conversions happen locally in your browser. Your JSON data is never uploaded to any server, ensuring complete privacy and security.