Compile .proto
files to plain TypeScript. Supports gRPC Node and gRPC Web.
Note
As of 2024, this project has adopted Rust as its primary programming language, replacing JavaScript. See the issue for the details.
I have limited availability to consistently maintain this project, as my time is primarily allocated to cutting new releases and implementing fixes on an ad hoc basis.
Become a maintainer? Send an email
- Passes all required conformance tests
- Supports well-known types
- Supports gRPC (
@grpc/grpc-js
) - Supports gRPC Web (
grpc-web
) - Supports json encoding (
toJson
,fromJson
) - Supports binary encoding (
toBinary
,fromBinary
) - Optimized for [de]serialization speed.
npm install -g protoc-gen-ts
protoc -I=sourcedir --ts_out=dist myproto.proto
version: v1
plugins:
- name: ts
path: ./node_modules/.bin/protoc-gen-ts
out: ./dist
syntax = "proto3";
enum Role {
ADMIN = 0;
MOD = 1;
}
message Author {
Role role = 2;
oneof id_or_name {
string id = 4;
string name = 5;
}
}
const author = Author.fromJson({
role: Kind.ADMIN,
name: "mary poppins",
});
// Serialize to binary
const bytes: Uint8Array = author.toBinary();
// Deserialize from binary
const received: Change = Change.fromBinary(bytes);
console.log(received.toJson())
./infra/test.sh
We need your constant support to keep protoc-gen-ts well maintained and add new features.
If your corporate has a OSS funding scheme, please consider supporting us monthly through open collective.