Protobuf to C# Converter

Paste a .proto schema. Get C# classes with auto-properties: drop them straight into a project, no protoc plugin required.

Input (.proto schema)

Output (C#)

Paste your Protobuf on the left and the C# code shows up here.

Or drop a file on this box, , or .

What this tool does

Somebody sends over the Protocol Buffers contract for a billing service and you want the matching C# DTOs this afternoon, not after adding Grpc.Tools to the .csproj and sitting through an MSBuild run. Paste the .proto here and you get plain classes with auto-properties plus the enums, ready for a Types.cs next to a minimal API, a Razor page or an integration test. Property names follow the protoc C# convention; the descriptor and parser plumbing that generated code carries is simply not there.

Type mapping is the boring-but-correct kind. string stays string (with = "" initialiser so nullable-reference projects do not complain). bool, int32, int64, uint32, uint64, float, double map to bool, int, long, uint, ulong, float, double respectively. bytes becomes byte[]. repeated T becomes List<T> and map<K, V> becomes Dictionary<K, V>, both initialised empty so a new object never hands you a null list, and well-known wrappers like google.protobuf.Timestamp are emitted as string (the proto3 JSON encoding for timestamps is RFC 3339, which is just a string at the wire level: see the proto3 JSON spec if you need the details).

Field names get the standard PascalCase treatment (order_id → OrderId, shipping_address → ShippingAddress) matching what the official C# protobuf reference generates. Enum values lose the SCREAMING_SNAKE prefix when the schema follows the convention of prefixing each value with the enum name (so ORDER_STATUS_PENDING in enum OrderStatus becomes OrderStatus.Pending). Output classes are flat: every nested message is hoisted to top level so you can split or rearrange them without untangling scopes. When two nested types share a name, say an Item inside both Order and Refund, each gets its parent's name in front (OrderItem, RefundItem) so the flat file still compiles. The conversion happens entirely in your browser; nothing about the schema is uploaded.

How to use it

Three steps. The output is ready to compile: paste it into a Types.cs file in your project.

1

Paste your .proto schema

Paste the schema on the left. A file with no syntax line still converts, and package, option and field options such as [deprecated = true] are read past quietly. import lines are not followed: a field typed common.Money comes out as public Money Total with no Money class behind it, so paste the imported message into the same editor if you want it generated too.

Field names are PascalCased, so amount_cents becomes AmountCents. Message and enum names are copied as written (only nested types that share a name get their parent's name in front), which means a message spelled invoice_line becomes public class invoice_line. option csharp_namespace is ignored too, so wrap the output in your own namespace.

2

Read the output

On the right: public class declarations with { get; set; } auto-properties for each message, plus public enum declarations for each enum. A using System.Collections.Generic; line is added when the schema uses repeated or map fields (so List and Dictionary resolve). Drop the file into a project, wrap in your namespace, you are done.

3

Wire it up

For pure DTO use, the classes are ready to serialise with System.Text.Json or Newtonsoft.Json. For real gRPC C# work (service implementations, streaming, deadlines) keep using Grpc.Tools for the wire-format types, and use this converter for hand-written wrappers, mapping layers, or test fixtures alongside the generated code.

When this actually saves time

Sketching DTOs for a new gRPC service

You are starting an ASP.NET Core gRPC service and want to read what the messages will look like in C# before committing to Grpc.Tools. Paste the .proto, eyeball the classes, decide if the field naming matches your team's style, then wire up codegen properly.

Hand-written mapping layer

Your generated gRPC types live in their own namespace and you want plain DTOs for your domain layer. The output here gives you clean classes without the metadata clutter of generated code: easy to map into and out of with AutoMapper or hand-rolled converters.

Reviewing a Protobuf schema change

A teammate added fields to a message in a PR. You want to see the C# shape implications without checking out the branch and running a build. Paste the new schema, diff against the current C# types, leave a focused review comment.

Test fixtures and quick scripts

You are writing a one-off LinqPad script or a console app that POSTs to a gRPC-gateway. Wiring up the full Protobuf toolchain for 50 lines of test code is overkill. Grab the classes from here, JSON-serialise them, send the request, move on.

Common questions

Is my schema sent anywhere?

No. The .proto is parsed and turned into C# by script on this page, and no request goes out while it happens, so internal service names and package paths stay on your machine. If you want proof, set DevTools to Offline and edit the schema: the classes keep updating.

Do these classes work with Grpc.Tools generated code?

They produce equivalent shapes, but they are not byte-for-byte identical. Grpc.Tools generates partial classes, parser registrations, descriptor wiring, and ancestor types from Google.Protobuf.IMessage: none of that is here. For real gRPC wire protocol work, use Grpc.Tools. For DTO-only code (e.g. JSON-over-HTTP gateways, mapping layers, test data), this output is fine.

Why are int64 and uint64 typed as long and ulong instead of string?

Because in C# they fit. Unlike JavaScript Numbers (which lose precision above 2^53), C# long handles the full int64 range natively, so there is no reason to fall back to string. If you are deserialising proto3 JSON where 64-bit ints arrive as strings (per the JSON mapping spec), System.Text.Json with JsonNumberHandling.AllowReadingFromString handles the conversion.

How does it handle the SCREAMING_SNAKE enum value convention?

Protobuf style guide recommends prefixing every enum value with the enum name in SCREAMING_SNAKE form. The converter detects this and strips it. ORDER_STATUS_UNSPECIFIED in enum OrderStatus becomes OrderStatus.Unspecified. If your enum does not follow that convention (some values prefixed, some not), the prefix-strip is skipped and values are PascalCased as-is.

Does it handle oneof?

Each member becomes its own property: oneof payer { string card_token = 5; string iban = 6; } turns into CardToken and Iban, both initialised to "". Nothing stops code setting both, and if neither is set System.Text.Json writes both keys as empty strings. When only one may go over the wire, make them string? without the initialiser and serialise with DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, or model the choice as a base class with one subclass per case.

What about google.protobuf.Timestamp and well-known types?

Timestamp is emitted as string (proto3 JSON encodes timestamps as RFC 3339 strings). Empty and Any become object placeholders: adjust to Google.Protobuf.WellKnownTypes.Any or a stronger type if your project pulls in the WKT package. The output is intentionally framework-free so you can drop it into any C# project without forcing a NuGet dependency.

Related tools

If you are juggling Protobuf, JSON, and C#, these pair well: