skillfed

cxxheaderparser

Modern C++ header parser

cxxheaderparser v1.9.2 365.7K downloads/30d#7,207 on PyPI153
Permissive license BSD-3-Clause Active released

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 cxxheaderparser

uv

uv add cxxheaderparser

poetry

poetry add cxxheaderparser

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: C++Programming Language :: PythonProgramming Language :: Python :: 3Topic :: Software DevelopmentTopic :: Software Development :: Code GeneratorsTopic :: Software Development :: Compilers

Tags

C++ header parser pythonparse C++ headersC++ binding generatorextract C++ declarationsC++ code analysis pythonC++ header analysisC++ to python bindings
c++-parsingbinding-generationcode-analysis

More Software Development packages