Skip to main content

Protosaurus

Protosaurus

Parse and create Protobuf messages at runtime in Python — no protoc required. Also includes a CLI to deserialize Protobuf from Kafka using kcat and a schema registry.

CI Wheels PyPI Python License

Installation

Requires Python >= 3.12.

uv add protosaurus

Or using pip:

pip install protosaurus

Usage

Parse and serialize Protobuf in Python

Protosaurus can parse .proto definitions at runtime without using protoc. This allows Protobuf byte arrays to be converted to JSON and vice versa. The Context object is thread-safe and can be shared across threads.

import json
from protosaurus import Context
from base64 import b64decode

# create a context which stores the proto schemas
ctx = Context()

# add protos by specifying name and content
ctx.add_proto('diet.proto',
    """
    syntax = "proto3";
    enum Diet {
        carnivorous = 0;
        herbivorous = 1;
    }
    """)

# the proto can be imported via the specified name
ctx.add_proto('animal.proto',
    """
    syntax = "proto3";
    import "diet.proto";
    message Animal {
        string name = 1;
        Diet diet = 2;
        double length = 3;
    }
    """)

# convert a message from base64 string...
data = ctx.to_json('Animal', b64decode('CglJZ3Vhbm9kb24QARkAAAAAAAAkQA=='))

# ...or hex string
data = ctx.to_json('Animal', bytes.fromhex('0a09496775616e6f646f6e1001190000000000002440'))

print(data)
# >>> '{"name":"Iguanodon","diet":"herbivorous","length":10}'


# fields left at their default are omitted...
data = ctx.to_json('Animal', b64decode('CglJZ3Vhbm9kb24='))

print(data)
# >>> '{"name":"Iguanodon"}'

# ...unless they are requested explicitly
data = ctx.to_json('Animal', b64decode('CglJZ3Vhbm9kb24='), include_defaults=True)

print(data)
# >>> '{"name":"Iguanodon","diet":"carnivorous","length":0}'


# convert json to protobuf
data = ctx.from_json('Animal', json.dumps({"name":"Iguanodon","diet":"herbivorous","length":10}))

print(data)
# >>> b'\n\tIguanodon\x10\x01\x19\x00\x00\x00\x00\x00\x00$@'

to_json accepts the following keyword-only options, all False by default:

Option Effect
include_defaults Print fields that do not track presence even when they hold their default: implicit-presence scalars, empty lists and empty maps. Fields with explicit presence (proto3 optional, submessages, oneof members) stay omitted when unset.
pretty Indent and line-break the output instead of emitting a single line.
proto_field_names Keep the field names as written in the .proto instead of lowerCamelCase.
enums_as_ints Print enum values as numbers instead of their names.
unquote_int64 Print 64-bit integers unquoted when the value round-trips through a double. Values that would lose precision stay quoted, so the JSON type of a field depends on its value.

Deserialize Protobuf from Kafka using a schema registry

Protosaurus also ships a CLI that can deserialize Protobuf messages from Kafka automatically when a schema registry is available:

kcat -C -e -F <kafka.config> -t <topic> -f "%o\\n%k\\n%R%s" | protosaurus - --schema-registry <url>

To disable SSL certificate verification (e.g. for self-signed certificates), pass --no-verify:

kcat -C -e -F <kafka.config> -t <topic> -f "%o\\n%k\\n%R%s" | protosaurus - --schema-registry <url> --no-verify

The JSON output options above are available as flags: --defaults, --pretty, --proto-field-names, --enums-as-ints and --unquote-int64.

kcat -C -e -F <kafka.config> -t <topic> -f "%o\\n%k\\n%R%s" | protosaurus - --schema-registry <url> --defaults --pretty

Using uvx (no installation required):

kcat -C -e -F <kafka.config> -t <topic> -f "%o\\n%k\\n%R%s" | uvx protosaurus - --schema-registry <url>

License

ISC License — see LICENSE for details.

Release files for protosaurus 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for protosaurus 0.5.0
File Size Uploaded
protosaurus-0.5.0.tar.gz 196.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for protosaurus 0.5.0
File
protosaurus-0.5.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
protosaurus-0.5.0-cp312-abi3-win32.whl CPython 3.12 abi3 Windows x86-32 Details
protosaurus-0.5.0-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details
protosaurus-0.5.0-cp312-abi3-musllinux_1_2_aarch64.whl CPython 3.12 abi3 Linux musl 1.2+ ARM64 Details
protosaurus-0.5.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
protosaurus-0.5.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.26+ ARM64, Linux glibc 2.28+ ARM64 Details
protosaurus-0.5.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details
protosaurus-0.5.0-cp312-abi3-macosx_10_14_x86_64.whl CPython 3.12 abi3 macOS 10.14+ x86-64 Details

Total release size: 10.3 MB

Release files / protosaurus-0.5.0.tar.gz

Download URL protosaurus-0.5.0.tar.gz
Size 196.9 kB
Tags Source
SHA-256 checksum
How to use checksums
da8180bda1ac71a7d0912351df48fb34e001fbfd4047f8b970ee93c6a6c9a897
BLAKE2b-256 checksum
How to use checksums
5ac4b21593b09fd5e061d1e98adefe9f95aab14d71bfb94025cfc8efbcdf7400
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / protosaurus-0.5.0-cp312-abi3-win_amd64.whl

Download URL protosaurus-0.5.0-cp312-abi3-win_amd64.whl
Size 759.0 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
db72d825a662b1bed5ec1d4b988b292da865f3a5783b97039952a1f04dbffc16
BLAKE2b-256 checksum
How to use checksums
ce050b681fd03b0a86558984f38ff1445a2959736c3d2d5d159e49aebc903305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / protosaurus-0.5.0-cp312-abi3-win32.whl

Download URL protosaurus-0.5.0-cp312-abi3-win32.whl
Size 686.4 kB
Tags CPython 3.12 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
66b892ac8d943ad56bc7237d12e6de3a1f49d3a24f24474b7352073128a20477
BLAKE2b-256 checksum
How to use checksums
197e4d99cd9abb7658449b2b726b1fa4fee57d3d4c3f4bcf50747a50fa792236
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / protosaurus-0.5.0-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL protosaurus-0.5.0-cp312-abi3-musllinux_1_2_x86_64.whl
Size 2.0 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
c6f820a2842ad7e754033b0e76c1a1c9479c85ee53978ba3764fdc026273c389
BLAKE2b-256 checksum
How to use checksums
97a05c030369a773db1b355b897632fb3ff59330a3007ea4213c556720f1838d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / protosaurus-0.5.0-cp312-abi3-musllinux_1_2_aarch64.whl

Download URL protosaurus-0.5.0-cp312-abi3-musllinux_1_2_aarch64.whl
Size 1.9 MB
Tags CPython 3.12 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
56addc377ce0608886c8029ddba660798a0fb84c4a747f92c509957eb85ebe00
BLAKE2b-256 checksum
How to use checksums
f142c7c98bdbcc17cbd8bb096d76c7e0f8629123683eb9b82a8407d5f1b76a12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / protosaurus-0.5.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL protosaurus-0.5.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.5 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
ce5f529d3a918568c717258db86774bdd5f31b6c1b463a6185daf92df9bef23f
BLAKE2b-256 checksum
How to use checksums
3462dc4a26d7a9185a9b1c20de4d6c08feb39a2f65507bc3b46abc18bebf70eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / protosaurus-0.5.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL protosaurus-0.5.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 1.4 MB
Tags CPython 3.12 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
91ca94b9776bb17f66dd85a173cfb9d515d4f25d7dc78e4841025d689a4f1900
BLAKE2b-256 checksum
How to use checksums
dd3f543a5e74abaab757ebf58d04edd27fa52a00de363d5843d16abe09cb0f72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / protosaurus-0.5.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL protosaurus-0.5.0-cp312-abi3-macosx_11_0_arm64.whl
Size 886.6 kB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f994ac7c19398b26bacee1320f8f6f37f741afcb35ff62127505f5ffde02c3b2
BLAKE2b-256 checksum
How to use checksums
53c4a163224377abd4323ee47d214e9c2962d382e5397267feb6967e104e7ab8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / protosaurus-0.5.0-cp312-abi3-macosx_10_14_x86_64.whl

Download URL protosaurus-0.5.0-cp312-abi3-macosx_10_14_x86_64.whl
Size 941.9 kB
Tags CPython 3.12 abi3 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
33f877d5b3e96ddcfe34d4b929b04b764b7ca1d4cd1ecd347a28aff9f804c9d6
BLAKE2b-256 checksum
How to use checksums
6ee364878a4e622fb27f41990c614c0404ee06abc4ba780aa8b5e58d52b2e3f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release history Release notifications | RSS feed

0.7.0

9 release files

0.6.0

9 release files

This release

0.5.0 This release

9 release files

0.4.0

8 release files

0.3.2

53 release files

0.3.0

49 release files

0.2.0

49 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page