A JavaScript and TypeScript implementation of Protocol Buffers for Node.js and browsers. Load .proto schemas, encode and decode binary messages, and optionally generate static or reflection-based code.
Overview
protobuf.js implements Google Protocol Buffers for JavaScript and TypeScript environments, including Node.js and browsers. It can work from .proto schema files without requiring the protoc compiler, and supports both runtime reflection and ahead-of-time code generation with matching TypeScript declarations.
Typical use starts with installing the package, loading a schema, then encoding and decoding messages. Message types expose validation, conversion between plain JavaScript objects and binary wire format, and length-delimited framing for streams. Field names from .proto files are converted to camelCase by default, with an option to keep original casing.
Optional tooling generates schema-specific modules in reflection or static modes, both sharing the same runtime package. A companion CLI can build reflection bundles, static code, and TypeScript declarations without protoc, or work alongside protoc via a plugin. Browser builds are available through a CDN with CommonJS, AMD, and global exports.
Beyond core binary APIs, extensions can handle ProtoJSON, text format, and descriptor conversion when reflection metadata is present. Service definitions support transport-agnostic RPC clients. The implementation is checked against the official conformance suite for Proto2, Proto3, and Editions wire formats, with optional coverage for text and JSON formats.
Key features
- .proto loading without protoc
- Reflection and static code generation
- TypeScript declarations from CLI
- Browser and Node.js runtimes
- Transport-agnostic service clients
- Plain object conversion options
- ProtoJSON and text format extensions
- Length-delimited message encoding
Use cases
- Binary API message serialization
- Shared schemas across JS services
- Browser clients using protobuf wire format
- gRPC-style services with custom transport
- Schema-driven TypeScript APIs