nanopb/nanopb logo

nanopb/nanopb

Free

Protocol Buffers with small code size

FreeFree tier
Type
Open Source

About nanopb/nanopb

Nanopb is a small code-size Protocol Buffers implementation written in ANSI C. It is specifically designed for embedded systems and microcontrollers, but is suitable for any memory-restricted environment. The library generates compact .pb.c and .pb.h files from standard .proto definitions, supports customization via .options files, and integrates with multiple build systems (CMake, Bazel, Meson, SCons). It is open-source and hosted on GitHub.

Key Features

Small code size optimised for microcontrollers and memory-constrained systems
Written in ANSI C for maximum portability
Generates .pb.c and .pb.h files from standard .proto definitions
Supports customization via .options files
Compatible with multiple build systems (CMake, Bazel, Meson, SCons, Make)
Includes a test suite for validation across compilers and platforms

Pros & Cons

Pros
  • Extremely lightweight and efficient for resource-limited hardware
  • Easy to integrate into existing C projects
  • Open-source with permissive license
  • Well-documented with examples and a forum community
  • Supports multiple build environments and package managers

Best For

Embedded systems developmentMicrocontroller-based projectsIoT device communicationMemory-constrained applications requiring Protocol Buffers serialization

FAQ

What is nanopb?
Nanopb is a small code-size Protocol Buffers implementation in ANSI C, designed for embedded systems and microcontrollers.
How do I generate headers from .proto files?
Use the nanopb generator: run `python generator/nanopb_generator.py myprotocol.proto` for source checkouts, or use the binary package's generator. The output is .pb.c and .pb.h files.
Can I customize the generated code?
Yes, you can create an .options file to control field types, maximum sizes, and other encoding behaviors.