skillfed

zcbor

Code generation and data validation using CDDL schemas

zcbor v0.9.1 383.1K downloads/30d#7,082 on PyPI165
Permissive license Apache Active released

What it is and what it does

zcbor is a CDDL schema processor that works in two modes: as a validator for YAML, JSON, and CBOR data, and as a code generator that produces C implementations for encoding and decoding CBOR according to a schema. The package includes a C library (also used standalone in Zephyr RTOS) that handles the low-level CBOR operations; when you generate C code, zcbor either references this library via CMake or copies its sources to your project.

The tool targets developers working with CBOR serialization who need either runtime validation in Python or embedded C implementations. CDDL (Concise Data Definition Language, RFC 8610) provides a powerful schema syntax for defining complex binary data structures, making zcbor useful for IoT, embedded systems, and any project where CBOR is the wire format.

Use it for:

  • Validate incoming CBOR messages against a schema before processing in a Python service.
  • Generate C code for CBOR encoding/decoding in embedded or IoT firmware projects.
  • Convert between YAML/JSON and CBOR formats with schema-enforced validation.
  • Define and validate complex binary protocols using CDDL schemas.
  • Integrate CBOR serialization into Zephyr RTOS or other embedded systems via the C library.

Worth the install?

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

zcbor validates and converts YAML/JSON/CBOR data against CDDL schemas, and generates C code for encoding/decoding CBOR data with schema validation.

Yes. zcbor fills a specific niche—CDDL-based CBOR validation and C code generation—with low install friction, active maintenance, no known vulnerabilities, and a permissive license. Install it if you need schema-driven CBOR handling in Python or C; skip it if you work exclusively with JSON or don't require CDDL's advanced schema features.

Install

zcbor on PyPI

pip

pip install zcbor

uv

uv add zcbor

poetry

poetry add zcbor

Installing zcbor

Before you install

Low friction install as a pure Python wheel. Actively maintained with recent commits and a stable release cadence; last release was 666 days ago with active repository status.

License in practice

Apache permissive license allows commercial and private use with minimal restrictions, suitable for most projects including those generating proprietary C code.

Quickstart

pip install zcbor
import zcbor
# Validate YAML/JSON/CBOR against a CDDL schema
zcbor.validate(data, schema_file)
# Or generate C code: zcbor code-gen schema.cddl --output-c

Requires Python >= 3.8; generated C code depends on the bundled C library included in the package.

Verify before relying

  • Whether the bundled C library requires compilation or system dependencies on target platforms
  • Performance characteristics when validating large CBOR datasets
  • Completeness of CDDL RFC 8610 feature coverage

Package facts

License Apache (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 3 — cbor2, pyyaml, regex
Maintenance actively maintained — 666 days since the last release
Last repo commit
First released
Downloads 383,063/month — #7,082 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: zcbor-0.9.1-py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: CProgramming Language :: Python :: 3Topic :: File Formats :: JSON :: JSON SchemaTopic :: Software Development :: Build ToolsTopic :: Software Development :: Code Generators

Tags

CBOR schema validationCDDL code generatorCBOR encoder decoderJSON YAML CBOR conversionC code generation CBORschema-based data validationCBOR C library
cbor-serializationcode-generationembedded-systems

More Build Tools packages