skillfed

nanopb

Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in microcontrollers, but fits any memory restricted system.

nanopb v0.4.9.1 422.6K downloads/30d#6,780 on PyPI5,520
Permissive license Zlib Active released

What it is and what it does

Nanopb is a Protocol Buffer compiler and runtime library designed for embedded systems and memory-constrained devices. It takes standard .proto files and generates minimal C code (pb_encode.c, pb_decode.c, pb_common.c) that can be compiled into your project. Unlike the full protobuf library, nanopb prioritizes small code size and low memory footprint, making it suitable for microcontrollers and other resource-limited environments.

The package provides a Python-based code generator that runs on your development machine to produce the C headers and source files from your .proto definitions. It integrates with common build systems (Make, CMake, SCons, Bazel, Conan) and platforms (Arduino, Zephyr, PlatformIO). The generated code depends only on protobuf as a runtime dependency for the generator itself, while the compiled C output has minimal external dependencies, making it ideal for bare-metal or deeply embedded applications.

Use it for:

  • Generate compact C serialization code for IoT devices and microcontroller firmware that need to exchange structured data over limited bandwidth or storage.
  • Build embedded systems that communicate with cloud services using Protocol Buffers without the overhead of a full protobuf runtime library.
  • Integrate Protocol Buffer message definitions into Arduino or STM32 projects where code size and memory are critical constraints.
  • Create firmware for devices running on Zephyr RTOS or other embedded operating systems that require efficient message serialization.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Nanopb is a code generator and runtime library that compiles Protocol Buffer definitions into minimal C code suitable for embedded systems and memory-constrained environments.

Yes, if you are building embedded C/C++ systems that need Protocol Buffer serialization. The active maintenance, permissive license, and wide integration with embedded platforms make it a solid choice. Install only if you have a C build system in place and need to generate code from .proto files; this is a build-time tool, not a runtime library for Python applications.

Install

nanopb on PyPI

pip

pip install nanopb

uv

uv add nanopb

poetry

poetry add nanopb

Installing nanopb

Before you install

Low install friction with a single runtime dependency on protobuf. The package is actively maintained with a recent release and 5520 repository stars, indicating stable community adoption.

License in practice

Licensed under Zlib (permissive), allowing use in commercial and proprietary projects with minimal restrictions.

Quickstart

pip install nanopb

# Generate C code from a .proto file
python -m nanopb.generator myprotocol.proto

# Or use the generator directly
from nanopb import generator
# Integrate with your build system to compile .pb.c and .pb.h files

Requires protobuf as a runtime dependency; C compiler and build system (Make, CMake, SCons, or Bazel) needed to compile the generated .pb.c and .pb.h files into your embedded project.

Verify before relying

  • Whether the PyPI package includes precompiled generator binaries or requires Python to run the generator
  • Performance characteristics or code-size benchmarks compared to other embedded protobuf implementations
  • Support status for Protocol Buffer versions beyond the current release cycle

Package facts

License Zlib (permissive)
Python support supports the current Python release (>=2.7)
Install friction low — pure-Python wheel
Runtime dependencies 1 — protobuf
Maintenance actively maintained — 621 days since the last release
Last repo commit
First released
Downloads 422,615/month — #6,780 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: nanopb-0.4.9.1-py2.py3-none-any.whl

Keywords: protobuf, protoc

License :: OSI ApprovedProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Build Tools

Tags

protobuf code generator embeddedprotocol buffers microcontrollerprotoc minimal C implementationsmall footprint serializationembedded protobuf compilermemory-efficient protobufnanopb generator tool
embedded-systemscode-generationprotobuf

More Build Tools packages