CoderTools

Protocol Buffers Tool

Encode, decode and validate Protocol Buffers messages

Proto Schema

Sample Schemas:

Input

Parse schema and select a message type to generate form fields

Output

Protocol Buffers Documentation

What is Protocol Buffers?

Protocol Buffers (Protobuf) is a language-neutral, platform-neutral extensible mechanism for serializing structured data, developed by Google. It is smaller, faster, and simpler than XML and JSON for data serialization.

Key Features

  • Language-neutral and platform-neutral
  • Smaller and faster than XML/JSON
  • Strong typing with schema definition
  • Backward and forward compatibility
  • Automatic code generation
  • Efficient binary encoding

How to Use This Tool

  1. Enter your .proto schema definition in the schema editor
  2. Click Parse Schema to validate and parse the schema
  3. Select the message type you want to work with
  4. For encoding: Enter JSON data and click Encode
  5. For decoding: Enter binary data and click Decode
  6. Use Raw Decode to analyze binary data without schema

Tool Features

Encode

Convert JSON data to Protocol Buffers binary format. Supports form-based input for easy data entry with type validation.

Decode

Convert Protocol Buffers binary data back to readable JSON format. Supports Base64, Hex, and C-style hex input formats.

Raw Decode

Analyze protobuf binary data without schema. Useful for debugging, reverse engineering, or analyzing unknown messages.

Form Input

User-friendly form interface that generates input forms based on your schema. Supports nested messages, enums, and repeated fields.

Proto Syntax Reference

Protocol Buffers uses a simple syntax for defining message types:

syntax = "proto3";

message Person {
    string name = 1;
    int32 id = 2;
    string email = 3;
    
    enum PhoneType {
        MOBILE = 0;
        HOME = 1;
        WORK = 2;
    }
    
    message PhoneNumber {
        string number = 1;
        PhoneType type = 2;
    }
    
    repeated PhoneNumber phones = 4;
}
  • syntax: Specifies the protobuf version (proto2 or proto3)
  • message: Defines a message type with fields
  • field: Each field has a type, name, and unique number
  • enum: Defines enumeration types
  • repeated: Marks a field as repeated (array/list)
  • optional: Marks a field as optional (proto3)

Scalar Types

Protocol Buffers supports various scalar types:

Type Description Default
int32, int64Signed integers (variable-length encoding)0
uint32, uint64Unsigned integers0
sint32, sint64Signed integers with ZigZag encoding (efficient for negative numbers)0
fixed32, fixed64Fixed-width unsigned integers (4 or 8 bytes)0
sfixed32, sfixed64Fixed-width signed integers (4 or 8 bytes)0
float, doubleFloating point numbers (32 or 64 bit)0.0
boolBoolean values (true/false)false
stringUTF-8 encoded text strings""
bytesArbitrary binary dataempty

Wire Types

Protobuf uses wire types to determine how to read values from binary data:

Wire Type Meaning Used For
0Varintint32, int64, uint32, uint64, sint32, sint64, bool, enum
164-bitfixed64, sfixed64, double
2Length-delimitedstring, bytes, embedded messages, packed repeated
532-bitfixed32, sfixed32, float

Best Practices

  • Use proto3 syntax for new projects - it's simpler and more widely supported
  • Keep field numbers stable - never reuse or change numbers for existing fields
  • Use meaningful field names that clearly describe the data
  • Reserve field numbers 1-15 for frequently used fields (they use 1 byte)
  • Use 'repeated' keyword for arrays/lists of values
  • Define enums for fields that have a fixed set of possible values

Frequently Asked Questions

What is Protocol Buffers (Protobuf)?

Protocol Buffers is a language-neutral, platform-neutral extensible mechanism for serializing structured data. It works like JSON, but is smaller, faster, and generates native language bindings. It is widely used in gRPC microservices.

How do I use this Online Protobuf Tool?

First, paste your `.proto` schema definition into the editor (or load a sample). Click 'Parse Schema' and select a Message Type. Then you can switch between 'Encode' (JSON → Binary) and 'Decode' (Binary → JSON) modes to process your data.

What is 'Raw Decode' (Decode without Schema)?

Raw Decode allows you to inspect a binary Protobuf message even if you don't have the `.proto` file. It parses the binary structure and displays Field Numbers, Wire Types, and Values, which is incredibly useful for debugging or reverse engineering unknown packets.

Is my data processed securely?

Yes. This tool runs 100% in your browser using JavaScript (protobuf.js). Your schemas, JSON data, and binary data are never sent to our servers, ensuring your sensitive information remains private.

Common Use Cases

  • Inter-service communication in microservices (gRPC)
  • Data storage and caching
  • Configuration files
  • Network protocols and APIs

References

Quick Menu

No recent tools