How does proto3 handle default values and field presence, and what does the 'optional' keyword do?

Last updated 8 July 2026

  • Proto3 scalars default to zero values (0, empty string, false, first enum value). Defaults are not sent on the wire, so unset and set-to-default look identical.

  • optional restores explicit presence tracking, generating a has_field() accessor (implemented like a single-field oneof).

  • Message-typed fields already track presence. repeated fields do not: an empty list is just empty.

  • https://protobuf.dev/programming-guides/proto3/
  • https://kreya.app/blog/protobuf-editions-explained/
All gRPC interview questions