Input

Output

What is Protocol Buffers (Protobuf)?

Protocol Buffers (Protobuf) is a language-neutral, platform-neutral data serialization format developed by Google. .proto files define the schema for messages and services, and are used extensively with gRPC APIs.

The Protobuf Formatter normalizes indentation (2 spaces per level), fixes block alignment, and removes trailing whitespace — helping teams maintain consistent and readable .proto schema files. You can find the full Protobuf Style Guide and source code on the protobuf GitHub repository.

How to Use

1

Paste your .proto content

Paste your Protocol Buffer schema into the left editor, or click Upload to load a .proto file.

2

Instant formatting

The formatter fixes indentation (2 spaces per level), normalizes message and service block structure, and removes trailing whitespace.

3

Copy or download

Use the Copy button to copy the result, or Download to save it as a .proto file.

Formatting Example

Example: Format a proto3 message definition

Unformatted input:

syntax="proto3";package api;message User{string name=1;int32 age=2;repeated string roles=3;bool active=4;}

Formatted output:

syntax = "proto3";
package api;

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

Frequently Asked Questions

What is the difference between proto2 and proto3?

Proto3 is the newer and recommended syntax. It removes required/optional field rules, uses simpler defaults, and has better support for JSON serialization. The formatter supports both versions.

Can I use this for gRPC service definitions?

Yes. gRPC service definitions use standard Protobuf syntax with service and rpc blocks, which the formatter handles correctly.

Does the formatter validate Protobuf syntax?

The formatter normalizes indentation and block structure but does not perform full semantic validation. Use protoc for complete compilation and validation.

What indentation style does the formatter use for .proto files?

The formatter follows the official Protobuf Style Guide, which recommends 2 spaces per indentation level. Nested blocks inside message, service, and enum declarations are all indented consistently.

Related Tools