JSON to Protobuf Schema Generator
This generator infers a Protocol Buffers schema from a JSON sample: nested objects become their own messages, arrays become repeated fields, and numbers are typed as int32, int64 or double based on the values actually present rather than assumed. Every record in an array is examined instead of just the first, so a field appearing in only some of them still gets a slot — the mistake that makes generated schemas subtly wrong. Field numbers are assigned in order, and it is worth understanding that once a schema is in use those numbers must never change: they are what the wire format actually carries, so reordering fields silently breaks compatibility.
How it works
Infers a Protocol Buffers schema from a JSON sample: nested objects become their own messages, arrays become repeated fields, and numbers are typed as int32, int64 or double based on the values actually present.
Every record in an array is examined rather than just the first, so a field that appears in only some of them still gets a slot. Field numbers are assigned in order — once a schema is in use those numbers must never change, so review them before adopting the output.
Everything runs in your browser — nothing you paste is sent to a server.
Field numbers are the contract
Protobuf does not transmit field names. The wire format carries field numbers, which is what makes it compact — and what makes those numbers a permanent part of the contract.
Once a schema is deployed:
- Never change an existing field's number.
- Never reuse the number of a deleted field — mark it
reservedinstead. - Adding a new field with a new number is always safe.
The numbers assigned here are sequential from 1, which is right for a new schema and wrong for an existing one.
Number types
A JSON sample where an ID happens to be 42 gives no hint that it will one day be 9 billion. Values above the int32 range are typed as int64 automatically, but if you know a field will grow, widen it before the schema is in use — changing it afterwards is a breaking change.
Frequently asked questions
How do I generate a proto schema?
Paste a representative JSON sample. The schema appears on the right with a message per nested object.
How are number types chosen?
Whole numbers within the int32 range become int32, larger ones int64, and anything with a decimal part becomes double. Basing this on the actual values avoids an overflow the first time a real ID appears.
Does it look at every record in an array?
Yes. Fields are merged across all of them, so a field present in only the third record still appears in the schema. Reading only the first record is how generated schemas end up missing fields.
Why do field numbers matter so much?
They are what the wire format carries — field names are not transmitted. Changing a number after a schema is in use makes old and new code read different fields from the same bytes.
Should I use the output as-is?
Treat it as a first draft. Check the field numbers, the number types and whether any field should be an enum before adopting it.
Is my JSON uploaded?
No. The inference runs entirely in your browser.
Related tools
JSON to JSON Schema Generator
This JSON to JSON Schema generator produces a draft 2020-12 schema from a sample payload.
JSON to TypeScript Converter
This JSON to TypeScript converter turns a sample payload into exported interfaces.
JSON to Go Struct Converter
This JSON to Go converter generates structs with the json tags encoding/json needs.