1. Home
  2. Developer tools
  3. Protobuf Formatter

Protobuf Formatter

Catch the protobuf mistakes that break wire compatibility, such as a reused field number, before they reach a code review or production.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Protobuf Formatter

  1. Paste a .proto file.
  2. Copy the formatted file.
  3. Fix the errors and warnings listed.

Features

  • Consistent indentation for messages, enums, oneofs and services
  • Duplicate field numbers and names per message
  • reserved numbers, ranges and names respected
  • 19000–19999 and the 536,870,911 maximum enforced
  • proto3 enums must start at 0; naming per the style guide

Supported formats

Input

  • PROTO

You get

  • PROTO

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the Protobuf Formatter is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Imports, extensions and message types are not resolved, so unknown types are not reported.

Guide

Formatting .proto files and catching field-number mistakes

Protocol Buffers describe messages for gRPC services, event streams and storage formats in .proto files. The format is forgiving about layout, so files from different authors drift into different styles, and it is unforgiving about field numbers, where a single reused number can corrupt data between versions. This tool reformats a .proto file and checks the numbering and naming rules.

Field numbers are the contract

On the wire, a message does not contain field names, only each field’s number and wire type followed by the value. That makes protobuf compact and lets old and new code interoperate, but it means the numbers are the real interface. Changing a field’s number, or giving a removed field’s number to a new field, makes old clients read data as the wrong field. The checker therefore treats numbering mistakes as errors.

Rules protoc enforces

Field numbers must be between 1 and 536,870,911, and the range 19000 to 19999 is reserved for the protobuf implementation itself. A number may be used only once per message, and so may a name. Fields inside a oneof share the numbering of the enclosing message. In proto3, the first value of every enum must be 0, because 0 is the default when a value is missing. The checker reports each of these with its line number.

Reserved numbers and names

When you delete a field, mark its number and name as reserved, for example reserved 5, 9 to 11; and reserved "coupon";. protoc then refuses any new field that reuses them. The checker reads reserved lists, including ranges ending in max, and flags fields that collide with them.

Style guide checks

The Protocol Buffers style guide asks for PascalCase message names, lower_snake_case field names and UPPER_SNAKE_CASE enum values, and these are reported as warnings. A further warning notes fields numbered above 15 while lower numbers are still free: numbers 1 to 15 encode their tag in one byte and 16 to 2047 in two, so frequently set fields should get the small numbers. A file without a syntax or edition line is compiled as proto2 by protoc, so that is flagged too.

Formatting

The formatter re-indents every block, messages, nested messages, enums, oneofs and services, with two spaces per level as in Google’s style, or four if you prefer. It normalises the spaces around =, puts a single space before opening braces and collapses runs of blank lines, while leaving comments and the order of declarations alone.

A worked example

The Sample shop.v1 schema reformats so that message Order { is followed by string id = 1;. It reports four errors: number 2 is already used on line 6 in Order (by the labels map), number 9 is reserved, 19001 is inside the implementation range, and the enum’s first value must be 0 in proto3. Three warnings cover the field Note, which should be lower_snake_case, the enum value shipped, which should be upper case, and the placed_at field numbered 19001 while low numbers are still free.

What a single file cannot show

The checker reads one file and does not resolve imports, so it cannot tell whether google.protobuf.Timestamp or other message types exist, whether a change breaks compatibility with the previous version, or how extensions are numbered. For those, run protoc or buf lint and buf breaking in CI.

Checked against the current version of the Protobuf Formatter on .

Frequently asked questions

Can I rename a field safely?

On the binary wire format, yes: only the number is sent, so old and new code still understand each other. Names do matter for JSON encoding and for generated code, so a rename is still a breaking change for clients that use the JSON mapping or compile against the old name.

What does option allow_alias = true do?

It lets two enum values share a number, so the same value has two names, for example a deprecated name and its replacement. Without the option, protoc rejects duplicate enum numbers, and so does this checker.

Why must I never reuse a field number?

The number, not the name, identifies a field on the wire. Old clients still sending field 5 with its old meaning would be read as your new field. Mark removed numbers reserved so nobody reuses them.

Why should frequent fields use numbers 1 to 15?

Each field is prefixed with its number and wire type. Numbers 1–15 fit that tag in one byte; 16–2047 need two. In messages sent millions of times, the byte adds up.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.