Protobuf options control how code is generated and how data is mapped. They are categorized by scope: File, Message, Field, or Service. The full set of standard options is defined in descriptor.proto.
option go_package: Defines the Go import path.option java_package: Defines the Java package.option optimize_for = SPEED;: Generates highly optimized (but larger) code. Alternatives:CODE_SIZE,LITE_RUNTIME.[deprecated = true]: Marks a field as deprecated.[json_name = "custom"]: Sets a custom JSON key.
edition = "2024"; option go_package = "github.com/example/v1"; option java_package = "com.example.v1"; option optimize_for = SPEED; message User { string user_id = 1 [json_name = "uid"]; string old_field = 2 [deprecated = true]; }
JSON
{
"uid": "01H8XGJWBWBAQ4",
"oldField": "still serialized"
}Next
Unknown Fields
How Protobuf preserves fields a decoder doesn't recognize, why that keeps old clients compatible with new schemas, and where unknown fields can bite.