Skip to content

protoruf

High-performance JSON ↔ Protobuf conversion, powered by Rust —
for Python, Node.js, the browser (WASM) and Rust.

PyPI Version GitHub release License


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 .proto compilation with protox, no external tools or codegen
  • 🎯 Complete Protobuf support — nested messages, enums, repeated fields, maps, oneof

Choose your target

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()