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.

It works line by line: a line ending in { opens a level, a line starting with } closes one, and everything between is indented two spaces per level, comments included. Runs of blank lines between messages shrink to a single one. It does not rewrite field numbers or reorder anything, so the schema stays wire-compatible. For naming and layout rules beyond indentation, see the Protobuf Style Guide; the compiler itself lives in the protobuf GitHub repository.

How to Use

1

Paste your .proto content

Paste a .proto on the left, or pick the file from your repo with Upload. Sample brings in a proto3 schema with a Person message, a PhoneType enum and a PersonService, all with their fields flush left, so you can watch the two-space levels appear.

2

Formats as you type

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

3

Copy or download

Copy sends the re-indented schema to the clipboard, and Download saves it as schema.proto. A one-line block such as enum Status { ACTIVE = 1; } is left on its one line, so expand it by hand first if you want it split.

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

Does it matter whether my file uses proto2 or 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