Format a .proto file

Indent Protocol Buffer declarations and separate major blocks for a readable .proto file.

freeworks offlinenothing uploaded
ToolProtobuf Editor
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The formatter adjusts a two-space indentation level around braces and inserts blank lines before top-level message, service, enum, and oneof blocks. Comments and declaration text are preserved without parsing a descriptor.

  • Two spaces are fixed for predictable generated output.
  • Unknown declarations are indented rather than semantically rewritten.

Worked example

User message with name and age fields
Format a Protocol Buffer message definition with proper indentation
Input
											syntax = "proto3";

message User {
string name = 1;
int32 age = 2;
}
										
Output
												syntax = "proto3";

message User {
  string name = 1;
  int32 age = 2;
}

											

When to use this

gRPC interfaces, code-generation schemas, and reviewed API contracts use .proto files.

Edge cases

  • A brace in a quoted option can confuse this line-based formatter.
  • Comment text is retained but not reflowed.
  • Nested blocks increase indentation by braces even with unusual option layout.

References