cantools
CAN BUS tools.
What it is and what it does
Cantools is a Python library for working with CAN (Controller Area Network) bus systems, primarily used in automotive applications. It reads and parses multiple database formats—DBC, KCD, SYM, ARXML 3 & 4, and CDD—that define the structure of CAN messages and signals. Once a database is loaded, the library provides high-level APIs to encode Python dictionaries into raw CAN frame bytes and decode incoming CAN frames back into human-readable signal values, handling both simple and multiplexed signals automatically.
Beyond the core encode/decode functionality, cantools includes command-line tools for real-world CAN bus work: a decoder that parses candump output (the standard Linux CAN capture format), a monitor for live bus observation, a plotter that visualizes signal values over time using matplotlib, and a C code generator for embedded systems. The library depends on bitstruct for bit-level manipulation, python-can for bus communication, textparser for format parsing, argparse_addons for CLI extensions, and crccheck for diagnostic frame validation.
Use it for:
- Decode candump logs from vehicle testing or diagnostics without manual frame parsing.
- Build Python scripts to send and receive CAN messages on a test bench or simulator.
- Parse automotive ARXML or DBC files to extract message and signal definitions for documentation or code generation.
- Implement diagnostic DID (Data IDentifier) encoding/decoding for vehicle communication protocols.
- Monitor live CAN bus traffic and plot signal trends for debugging or validation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Cantools parses automotive CAN bus database files (DBC, KCD, SYM, ARXML, CDD) and provides encoding/decoding of CAN messages with support for multiplexing, diagnostics, and command-line tools for monitoring and visualization.
Yes. Cantools is well-maintained, actively developed, carries no security vulnerabilities, and has low install friction. It is the standard choice for CAN bus work in Python and covers the full workflow from database parsing through encoding, decoding, and visualization. Install it if you work with automotive CAN systems, vehicle diagnostics, or need to process CAN bus captures.
Install
cantools on PyPI
pip
pip install cantoolsuv
uv add cantoolspoetry
poetry add cantoolsInstalling cantools
Before you install
Low friction: pure Python wheel with five straightforward runtime dependencies. Actively maintained with a recent release; last commit 2026-08-14 and 2267 repository stars indicate steady development.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install cantools
import cantools
db = cantools.database.load_file('motohawk.dbc')
message = db.get_message_by_name('ExampleMessage')
data = message.encode({'Temperature': 250.1, 'Enable': 1})
decoded = db.decode_message(message.frame_id, data)
Requires Python >= 3.10. Optional matplotlib dependency for plot subcommand must be installed separately with cantools[plot].
Verify before relying
- Whether the C source code generator is production-ready or primarily for reference.
- Performance characteristics when handling large or complex ARXML files.
- Extent of support for ARXML 3 vs. ARXML 4 features and known limitations.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — bitstruct, python-can, textparser, argparse_addons, crccheck |
| Maintenance | actively maintained — 40 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,193,654/month — #4,235 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cantools-42.0.3-py3-none-any.whl
Keywords: can, can bus, arxml, dbc, kcd, automotive
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
canmatrixCanmatrix parses, manipulates, and converts CAN…
permissive · top 5,000 on PyPI
odxtoolsodxtools parses and processes ODX (Open…
permissive · top 5,000 on PyPI
ldfparserParses LIN Description Files (LDF) to extract…
permissive · top 5,000 on PyPI
powertrain-buildA CI build system for testing…
permissive · top 15,000 on PyPI
python-canProvides Python abstractions and utilities for…
copyleft · top 5,000 on PyPI
asammdfasammdf parses, edits, and exports ASAM MDF…
copyleft · top 5,000 on PyPI
vcdvcdParses Verilog value change dump (VCD) files…
unclear · top 15,000 on PyPI
udsoncanImplements the Unified Diagnostic Services…
permissive · top 15,000 on PyPI
autosar-dataPython bindings for reading, writing, and…
unclear · top 15,000 on PyPI
canopenA Python implementation of the CANopen standard…
permissive · top 5,000 on PyPI