The Protobuf ecosystem had a large shake-up with the evolution of proto2 to proto3. To evolve Protobuf with as few breaking changes as possible, Protobuf Editions moved many controversial decisions into options, called features, so you get more choice in how your Protobuf types behave:
- Field Presence: whether a reader can tell a field that was never set apart from one set to its default value. Choose
IMPLICIT(the proto3 behavior) orEXPLICIT(the proto2 behavior); the Field Presence page covers the tradeoff. - Enum Type: where a value the enum does not declare ends up.
OPENkeeps it in the field;CLOSEDmoves it to the unknown fields. - Repeated Encoding: Standardize on
PACKED(for efficiency) orEXPANDED(for compatibility).
You can set a feature for an entire file and then override the feature on individual messages, fields, enums, services, and methods. This allows you to adopt new behaviors without doing weird splitting of Protobuf files or requiring entire Protobuf files to change behaviors all at once. Editions remove the need to have a proto4 as new behaviors can be introduced in each new edition.
Three editions have shipped so far: edition 2023, which unified proto2 and proto3; edition 2024, which added symbol visibility, import option, and naming-style enforcement; and edition 2026 (protobuf 36.x), which defaults symbol visibility to strict, rejects field names that collide in generated code, caps the size of messages and enums, and adds custom JSON names for enum values. The editions overview and the feature settings reference track exactly what each edition changes.
edition = "2024"; package demo.v1; // Set for the whole file... option features.enum_type = CLOSED; enum Unit { UNIT_UNSPECIFIED = 0; UNIT_CELSIUS = 1; } enum Status { // ...and overridden on one enum. option features.enum_type = OPEN; STATUS_UNSPECIFIED = 0; STATUS_ACTIVE = 1; }
Edition by edition
Each edition changes the defaults for some features, adds new syntax and options, and removes old ones. This section walks through them in order and what changed from the one before.
Before editions: proto2 and proto3
2008 and 2016
The syntax line at the top of a file chose between two fixed sets of behavior.
- syntax = "proto2";
- Explicit presence on every singular field, closed enums,
required, custom default values, extensions on any message, and groups. - syntax = "proto3";
- Drops
required, custom defaults, and general extensions. Scalar fields get implicit presence, enums are open, repeated scalars are packed, and the JSON mapping is standard. Theoptionalkeyword came back in 2021 to give a proto3 scalar explicit presence again.
syntax = "proto3"; package shop.v1; message Order { string id = 1; // Implicit presence: zero and unset look the same. int64 total_cents = 2; // optional gives one field explicit presence. optional string coupon = 3; }
Edition 2023
Protobuf 27, May 2024
Replaces the syntax switch with features. Each behavior proto2 and proto3 disagreed on becomes a setting with a default, and the default can be changed for a whole file or on the individual elements each feature applies to.
- features.field_presenceDefault
- Every singular field can tell unset from zero without
optional.IMPLICITrestores the proto3 behavior, andLEGACY_REQUIREDis the editions form of the proto2requiredlabel. - features.enum_typeDefault
- The proto3 behavior.
CLOSEDkeeps proto2 enums working as they did. - features.repeated_field_encodingDefault
EXPANDEDwrites a tag per element. proto2 did that unless a field asked for packing.- features.utf8_validationDefault
- A runtime checks that strings are valid UTF-8. proto3 did the same.
NONEskips the check, like proto2. - features.message_encodingDefault
- How a nested message is written. proto2 groups used
DELIMITED. - features.json_formatDefault
- The compiler checks that the schema maps to JSON cleanly. Two fields can't land on the same key.
LEGACY_BEST_EFFORTlets that through, like proto2. - Back from proto2
- Any message can have extensions again. Custom default values are back too, on fields with explicit presence.
Generated code
- features.(pb.go).api_levelDefault
- Picks the Go API.
API_OPENis structs with exported fields.API_OPAQUEhides the fields behind accessors.API_HYBRIDgenerates both, for code that is partway through the move. - features.(pb.cpp).string_typeDefault
- The C++ type for a string field's accessors.
VIEWis astring_view. The others areSTRINGandCORD. - features.(pb.cpp).legacy_closed_enumDefault
- Set to
true, a field treats its enum as closed andenum_typeis ignored. C++ and Java did this to the enum fields of a proto2 file. Java has its own copy under(pb.java). Both were deprecated on arrival. - features.(pb.java).utf8_validationDefault
VERIFYturns the UTF-8 check on for Java alone. Deprecated in edition 2024.
Removed
- optional, required
- Use
features.field_presence. Arequiredfield becomesLEGACY_REQUIRED. - group
- Write a message field and set
features.message_encoding = DELIMITEDon it. - [packed = true]
- Replaced by
features.repeated_field_encoding. - java_string_check_utf8
- Replaced by
features.(pb.java).utf8_validation. - reserved "name";
- Drop the quotes:
reserved name;
edition = "2023"; package shop.v1; // Keeps proto3's implicit presence for the file. option features.field_presence = IMPLICIT; message Order { string id = 1; int64 total_cents = 2; // This field was optional in proto3. string coupon = 3 [features.field_presence = EXPLICIT]; }
edition = "2023"; option features.enum_type = CLOSED; option features.repeated_field_encoding = EXPANDED; option features.utf8_validation = NONE; option features.json_format = LEGACY_BEST_EFFORT;
Edition 2024
Protobuf 32, August 2025
Keeps the 2023 presence, enum, and packing defaults, adds control over what a file exposes to the files that import it, and starts enforcing the style guide's names. This guide's examples use it.
- export, local
- They go in front of a message or enum. An
exporttype can be used from other files. Alocaltype can't. - features.default_symbol_visibilityDefaultnow
- The setting for a type with no modifier. Top-level types can still be imported. Nested types are local now. A file that refers to one stops compiling until the type says
export.LOCAL_ALLmakes everything local.STRICTis what edition 2026 uses. - import option
- For a file you import only to use the custom options it defines. Its types do not come into scope, and its descriptors are not needed at runtime. It has to come after the ordinary imports.
- features.enforce_naming_styleDefaultnow
- The compiler rejects names that break the style guide. Packages, fields, and oneofs have to be
lower_snake_case. Enum values have to beUPPER_SNAKE_CASE. Messages, enums, services, and methods have to bePascalCase. Old names can stay if the file setsSTYLE_LEGACY.
Generated code
- features.(pb.go).api_levelDefaultnow
- Go gets the Opaque API unless a file asks for another.
- features.(pb.go).strip_enum_prefixDefault
STRIP_ENUM_PREFIX_STRIPdrops the enum's name from the front of its Go value names. Go would otherwise print it twice.STRIP_ENUM_PREFIX_GENERATE_BOTHgenerates both names.- features.(pb.cpp).string_typeDefaultnow
- C++ string accessors return a
string_view. - features.(pb.cpp).enum_name_uses_string_viewDefaultnow
- The C++ function that returns an enum value's name returns a
string_viewtoo. - features.(pb.java).nest_in_file_classDefaultnow
- Java classes are generated on their own, which is what
java_multiple_files = trueused to ask for.YESnests one inside the class generated for its file. That class gets a new default name too, the file name with aProtosuffix. - features.(pb.java).large_enumDefault
- Set to
true, Java generates a class in place of anenum, for an enum with more values than a Java enum can hold.
Removed
- import weak
- Replaced by
import option. - ctype
- Replaced by
features.(pb.cpp).string_type. - java_multiple_files
- Replaced by
features.(pb.java).nest_in_file_class.
edition = "2024"; package shop.v1; // Brings in the options, not the file's types. import option "buf/validate/validate.proto"; // Top-level types are importable by default. message Order { string id = 1 [(buf.validate.field).string.uuid = true]; Status status = 2; // A nested type is local unless it says export. export enum Status { STATUS_UNSPECIFIED = 0; STATUS_PAID = 1; } } local message Draft { Order order = 1; }
edition = "2024"; import option "google/protobuf/cpp_features.proto"; import option "google/protobuf/go_features.proto"; import option "google/protobuf/java_features.proto"; option features.enforce_naming_style = STYLE_LEGACY; option features.default_symbol_visibility = EXPORT_ALL; option features.(pb.go).api_level = API_OPEN; option features.(pb.cpp).string_type = STRING; option features.(pb.cpp).enum_name_uses_string_view = false; // The Java feature can't be set for a file. // It goes on each message, enum, and service. message Order { option features.(pb.java).nest_in_file_class = YES; }
Edition 2026
Protobuf 36, August 2026
Tightens the 2024 defaults. Messages and enums get a size cap. An enum value can pick its JSON name. There is no new syntax.
- features.default_symbol_visibilityDefaultnow
- Every type is local unless it says
export. Only a top-level type can say it. A nested type that other files use has to move to the top level. That changes its full name. To keep nested exports, set the feature toLOCAL_ALL. - features.enforce_naming_styleDefaultnow
- Also rejects field names that collide in generated code. Next to a field named
x, these are out:has_x,get_x,set_x,clear_x, andx_value. No field can be nameddescriptor. - features.enforce_proto_limitsDefaultnow
- New in this edition. A message can have 1500 fields and 1000 oneofs. A oneof can have 1200 fields. An enum can have 1700 values. The compiler rejects anything bigger.
LEGACY_NO_EXPLICIT_LIMITSlifts the cap, but only on the one message, oneof, or enum it is set on. It can't be set for a whole file. The Limits page covers message size too. - (pb.enumvalue.json).string
- A custom JSON name for an enum value.
json_namedoes the same for a field. Import it fromgoogle/protobuf/json_options.proto. The Standard Options page shows what it does to the JSON. It only works in an edition 2026 file. The option is marked with the edition that introduced it, and the compiler checks. Only features and their values had that marker before.
Generated code
- (pb.file.cpp).namespace
- Sets the C++ namespace for the generated code. Without it the namespace follows the package. It is imported from
google/protobuf/cpp_options.proto. - features.(pb.csharp).nullable_reference_typesDefault
- Set to
true, generated C# carries nullable reference type annotations.
Removed
- cc_enable_arenas
- C++ arenas are on in every edition, and the option had stopped doing anything.
edition = "2026"; package shop.v1; import option "buf/validate/validate.proto"; import option "google/protobuf/json_options.proto"; // Nothing can be imported now unless it says export. export message Order { string id = 1 [(buf.validate.field).string.uuid = true]; Status status = 2; } // A nested type can't say export anymore, // so Status moved up a level. export enum Status { STATUS_UNSPECIFIED = 0; STATUS_PAID = 1 [(pb.enumvalue.json).string = "paid"]; } // Local without having to say so. message Draft { Order order = 1; }
{
"id": "0b9e2f6c-5a1d-4c3e-9f7a-2d8b6e4c1a90",
"status": "paid"
}edition = "2026"; option features.enforce_naming_style = STYLE2024; option features.default_symbol_visibility = EXPORT_TOP_LEVEL;
There is no file-level setting for the size limits. An oversized type has to opt out itself.
Defaults by edition
Every feature has a default in every edition. proto2 and proto3 have defaults too. The compiler treats them as two more editions. In this table a value stretches across the editions that share it. Where a row breaks, that edition changed the default.
| Feature | proto2 | proto3 | 2023 | 2024 | 2026 |
|---|---|---|---|---|---|
| field_ | |||||
| enum_ | |||||
| repeated_ | |||||
| utf8_ | |||||
| message_ | |||||
| json_ | |||||
| enforce_ | |||||
| default_ | |||||
| enforce_ | |||||
| Generated code | |||||
| (pb. | |||||
| (pb. | |||||
| (pb. | |||||
| (pb. | |||||
| (pb. | |||||
| (pb. | |||||
| (pb. | |||||
| (pb. | |||||
| (pb. | |||||
| (pb. | |||||
In a schema each name takes a features. prefix. The generated-code features belong to one language each and need its features file imported, such as google/protobuf/go_features.proto. A feature can only be set from the edition that introduced it on. The feature settings reference has every value each one accepts.
How the language got here
Protobuf has been public since 2008. These are the releases that changed the language, from proto2 through editions.
Further Reading
- Protobuf Editions are here: don't panic
An overview of editions for teams on proto2 or proto3, and how to migrate.
Next
Standard Options
Protobuf options at the file, message, and field level: what the well-known options do and how options change generated code without changing the wire format.