Protocol Buffers

Style Guide

This document provides a style guide for .proto files. By following these conventions, you'll make your protocol buffer message definitions and their corresponding classes consistent and easy to read.

Message And Field Names

Use CamelCase (with an initial capital) for message names – for example, SongServerRequest. Use underscore_separated_names for field names – for example, song_name.

message SongServerRequest {
  required string song_name = 1;

Using this naming convention for field names gives you accessors like the following:

  const string& song_name() { ... }
  void set_song_name(const string& x) { ... }

  public String getSongName() { ... }
  public Builder setSongName(String v) { ... }


Use CamelCase (with an initial capital) for enum type names and CAPITALS_WITH_UNDERSCORES for value names:

enum Foo {

Each enum value should end with a semicolon, not a comma.


If your .proto defines an RPC service, you should use CamelCase (with an initial capital) for both the service name and any RPC method names:

service FooService {
  rpc GetSomething(FooRequest) returns (FooResponse);

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.