How to Convert Go to Protobuf - Step by Step Guide
Input Your Go Struct Definitions
Start by entering your Go struct definitions that you want to turn into a Protocol Buffer schema:
Example: Go Struct Input
Here's a typical Go struct definition ready for protobuf conversion:
package main type User struct { ID int32 `json:"id"` Name string `json:"name"` Email string `json:"email"` Roles []string `json:"roles"` Active bool `json:"active"` Profile UserProfile `json:"profile"` } type UserProfile struct { Department string `json:"department"` ExperienceYears int32 `json:"experience_years"` Skills []string `json:"skills"` }
Automatic Schema Generation
The converter reads your Go structs and generates a matching Protocol Buffer schema:
Example: Generated Protobuf Schema
The same Go structs, now expressed as a protobuf schema:
syntax = "proto3"; package main; message User { int32 id = 1; string name = 2; string email = 3; repeated string roles = 4; bool active = 5; UserProfile profile = 6; } message UserProfile { string department = 1; int32 experience_years = 2; repeated string skills = 3; }
Copy or Download the .proto File
Take the generated schema with you:
Frequently Asked Questions
What Go code should I paste?
Paste Go struct definitions: type X struct { ... }. Each struct becomes a protobuf message, each field becomes a numbered field, and a struct field whose type is another struct becomes a nested message.
Is my Go code sent to a server?
Yes. When you click Convert, the code in the editor is sent to our server, which builds the .proto schema and sends it back. Nothing is sent while you type, paste or upload, and nothing is kept — a reload starts with an empty editor. Leave passwords, API keys and other secrets out of the code you convert.
Are field numbers and example values kept exactly?
Yes. The schema comes back as plain text and is shown exactly as received, so field numbers and any values in it — long IDs like 8901240544102066246, codes like 00501, prices like 14.50 — are never rounded or reformatted.
How are Go types mapped to protobuf?
string stays string, int32 and int64 keep their width, float32 becomes float and float64 becomes double, and bool stays bool. A slice or array ([]T) becomes a repeated field, and a nested struct becomes a nested message.
How are Go field names converted?
Go field names (usually CamelCase) come across as snake_case, which is the protobuf convention — for example ExperienceYears becomes experience_years. A json struct tag, if present, is used for the field name.
Is it free, and can I go the other way?
Yes, and there is no sign-up. Every conversion goes through our server, so when a lot of requests arrive at once you may be asked to wait a minute and try again. Starting from JSON instead of Go? JSON to Protobuf builds a schema from a JSON sample.
Related Tools
Go to JSON
Convert Go structs and data structures to JSON format
Go to YAML
Convert Go structs to YAML configuration format
Go to TOML
Convert Go structs to TOML configuration format
Go to XML
Convert Go structs to XML format
Go to CSV
Export Go data to CSV for spreadsheets and data analysis
Go to SQL
Generate SQL CREATE TABLE and INSERT statements from Go structs