cxxheaderparser
Modern C++ header parser
What it is and what it does
cxxheaderparser is a pure-Python C++ header parser designed to extract structural information from C++ headers for use in binding generators and code analysis tools. It parses syntactically valid C++ including modern features (C++11 and beyond) and produces either a visitor-style interface for custom processing or a simple data structure containing all parsed elements. The parser does not produce a full AST, does not validate C++ correctness, and requires preprocessed input if macros are present—it trades completeness for practicality, aiming to handle common C++ patterns while acknowledging it may struggle with obscure or overly complex constructs.
The package is a rewrite of CppHeaderParser, designed to provide a cleaner, documented API and better support for modern C++ features. It ships with a command-line interface for dumping parsed headers in multiple formats (pprint, JSON, dataclasses repr) and is actively maintained with support for Python 3.6+.
Use it for:
- Generate language bindings for C++ libraries by extracting function and class signatures from headers
- Analyze C++ codebases to build documentation or dependency graphs without invoking a compiler
- Extract type information and method signatures for IDE integration or code generation tools
- Preprocess and parse C++ headers in build systems where full compilation is not feasible
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses C++ header files into Python data structures, extracting class definitions, functions, and modern C++ constructs without requiring a full AST or compiler validation.
Yes, if you need to parse C++ headers for binding generation or code analysis. Low install friction, active maintenance, no security issues, and permissive licensing make it a practical choice. Caveat: not suitable if you need full AST semantics, C++ validation, or comprehensive C++17/20 support—use Clang or a compiler for those cases.
Install
cxxheaderparser on PyPI
pip
pip install cxxheaderparseruv
uv add cxxheaderparserpoetry
poetry add cxxheaderparserInstalling cxxheaderparser
Before you install
Low friction: pure Python wheel with only dataclasses as a runtime dependency (built-in for Python 3.7+). Active maintenance with a release 25 days ago.
License in practice
BSD-3-Clause permissive license allows commercial and private use with attribution; no restrictions on derivative works or distribution.
Quickstart
pip install cxxheaderparser
from cxxheaderparser import parse_file
header_data = parse_file('myheader.h')
print(header_data.classes, header_data.functions)
Requires a C++ preprocessor if input headers contain macros; use pcpp, GCC, or MSVC preprocessing before parsing, or enable preprocessor support via cxxheaderparser.preprocessor module.
Verify before relying
- Whether the package handles all C++17/20 constructs or only a subset (description notes not all are supported yet)
- Performance characteristics when parsing very large or deeply nested header files
- Accuracy of binding-generator output for complex template specializations
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — dataclasses |
| Maintenance | actively maintained — 25 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 365,721/month — #7,207 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cxxheaderparser-1.9.2-py3-none-any.whl
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
pycparserpycparser is a C language parser written in…
permissive · top 100 on PyPI
tree-sitter-cppProvides a C++ language grammar for…
permissive · top 5,000 on PyPI
CppHeaderParserParses C++ header files and extracts their…
permissive · top 15,000 on PyPI
cppcleancppclean analyzes C++ source code to identify…
permissive · top 15,000 on PyPI
pcppA pure Python implementation of a C99…
permissive · top 15,000 on PyPI
ctypesgenctypesgen parses C header files and…
permissive · top 15,000 on PyPI
pybind11-globalA header-only C++ library that generates Python…
permissive · top 15,000 on PyPI
pyclibraryParses C header files and automates…
permissive · top 15,000 on PyPI
pybind11pybind11 is a header-only C++ library that…
permissive · top 1,000 on PyPI
PyBindGenPyBindGen generates clean C or C++ code that…
copyleft · top 15,000 on PyPI