Protobuf Formatter Online

Beautify or minify Protocol Buffer (.proto) files instantly in your browser.

Indent:
INPUT0 chars
OUTPUT

When a Protobuf formatter is the right tool

Use this page to indent or compact a .proto file in the browser. Paste the text, choose Beautify (2- or 4-space) or Minify, and read the live output. It does not compile or lint the schema. For GraphQL documents, seeGraphQL Formatter.

Use cases

Re-indenting a messy file

Load Sample, then Beautify. After a block closes, the next top-level message, service, or enum is separated by a blank line. Opening comments that use // stay on their line.

Compacting a file

Minify removes // comments and most extra spaces. Skip it if options or strings contain semicolons or hashes you need to keep intact.

How formatting works

Depth increases when a line’s non-comment text ends with {, and decreases when a line is only }. Extra runs of blank lines are collapsed to at most one.

Example — Beautify (2-space) shape, including lost blanks at the top
syntax = "proto3";
package user.v1;
import "google/protobuf/timestamp.proto";
option go_package = "github.com/example/user/v1;userv1";

service UserService {
  rpc GetUser(GetUserRequest) returns (User);
}

message User {
  string id = 1;
  string name = 2;
}

What this tool does not do

It does not distinguish proto2 from proto3, rewrite field numbers, or format /* */ comments specially. Formatting stays in your browser.

How to use Protobuf Formatter

  1. Paste a .proto file, or use Load Sample.
  2. Choose Beautify or Minify (and 2- or 4-space indent for Beautify).
  3. Copy when the result looks right. Clear resets the input.

Frequently asked questions

How does Protobuf Formatter work?

Beautify or Minify runs as you type. Beautify trims lines, drops blank lines, indents by brace depth (2 or 4 spaces), and inserts a blank line before a top-level message, service, enum, extend, or option that follows a closing brace. // comments are ignored when counting braces but kept on the line. /* */ comments are not treated as comments. This is an indent helper, not a proto2 or proto3 parser and not protoc.

Does Minify preserve strings that contain semicolons?

Not always. Minify strips // comments, joins the file onto one line, and then inserts a space after every semicolon it sees, with no string awareness. An option such as option go_package = "github.com/example/user/v1;userv1"; can become "...v1; userv1". Prefer Beautify when your .proto has semicolons inside quotes.

Are proto2 and proto3 validated?

No. The tool does not parse syntax, field numbers, or options. A proto2 or proto3 file will indent the same way if it uses braces. Load Sample is a proto3-looking sketch with a service, messages, and an enum; after Beautify, the blank lines between syntax, package, and imports are not restored.

Is my .proto uploaded?

No. Formatting runs in your browser. Clear empties the input. An error panel exists in the UI, but the current functions do not throw.

Related tools and guides

References