protoruf¶
High-performance JSON ↔ Protobuf conversion, powered by Rust —
for Python, Node.js, the browser (WASM) and Rust.
Overview¶
protoruf converts between JSON and Protobuf dynamically — no protoc, no generated
classes. You compile a .proto to a descriptor once, then convert in both directions at Rust
speed. It is built on prost-reflect and
protox.
A single pure-Rust core powers every target through a thin binding layer, so the conversion logic is shared, never duplicated:
| Target | Package | Install |
|---|---|---|
| Python | protoruf |
pip install protoruf |
| Node.js | @protoruf/node |
from GitHub Releases by URL — npm coming soon (guide) |
| Browser (WASM) | @protoruf/wasm |
from GitHub Releases by URL — npm coming soon (guide) |
| Rust | core crate | — |
Why protoruf?¶
- ⚡ Blazing fast — core logic implemented in Rust
- 🔁 One core, four targets — identical semantics across Python / Node / Browser / Rust
- 🔒 Type-safe — explicit message types prevent serialization errors
- 📦 No
protoc— built-in.protocompilation with protox, no external tools or codegen - 🎯 Complete Protobuf support — nested messages, enums, repeated fields, maps, oneof
Choose your target¶
-
Python
pip install protoruf— with direct Pydantic integration. -
Node.js
@protoruf/node— native addon, full filesystem access. Install from GitHub Releases (npm coming soon). -
Browser (WASM)
@protoruf/wasm— runs entirely in the browser, sandboxed. Install from GitHub Releases (npm coming soon). -
Rust
The shared engine behind every binding.
Architecture¶
┌───────────────────────────────────────────────────────────────┐
│ Python Node.js Browser (WASM) Rust │
│ (PyO3) (napi-rs) (wasm-bindgen) (core API) │
├───────────────────────────────────────────────────────────────┤
│ core.rs — pure-Rust engine │
│ .proto compilation · JSON ↔ Protobuf · descriptor pool │
├───────────────────────────────────────────────────────────────┤
│ protox │ prost-reflect │ serde_json │
└───────────────────────────────────────────────────────────────┘
Each binding only translates types & errors around the core; building one target never pulls in another's dependencies.
Features¶
| Feature | Description |
|---|---|
| JSON ↔ Protobuf | Bidirectional conversion with full type safety |
| Proto compilation | Compile .proto files without external tools (compileProtoFromSources works in-memory, even in the browser) |
| Nested messages | Full support for nested message types |
| Enums | Automatic name ↔ number handling |
| Repeated fields & maps | Lists, arrays and dictionary structures |
| Oneof fields | Support for union types |
| DescriptorCache | Pre-decoded pool for high-throughput conversion |
| Pydantic integration | Python: direct pydantic_to_protobuf() / protobuf_to_pydantic() |