skillfed

pycparser

C parser in Python

pycparser Permissive license BSD-3-Clause Active 3,559 v3.0 released

Install

pycparser on PyPI

pip

pip install pycparser

uv

uv add pycparser

poetry

poetry add pycparser

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 204 days since the last release
Last repo commit
First released
Popularity one of the 100 most-downloaded packages on PyPI (30-day window, as of 2026-08-13)
Known vulnerabilities none known (OSV.dev, checked 2026-08-13)

Evidence: pycparser-3.0-py3-none-any.whl

Development Status :: 5 - Production/StableProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

About pycparser

from the package's own PyPI description — quoted content, verbatim

=============== pycparser v3.00 ===============

.. image:: https://github.com/eliben/pycparser/workflows/pycparser-tests/badge.svg :align: center :target: https://github.com/eliben/pycparser/actions


.. contents:: :backlinks: none

.. sectnum::

Introduction

What is pycparser?

pycparser is a parser for the C language, written in pure Python. It is a module designed to be easily integrated into applications that need to parse C source code.

What is it good for?

Anything that needs C code to be parsed. The following are some uses for pycparser, taken from real user reports:

  • C code obfuscator
  • Front-end for various specialized C compilers
  • Static code checker
  • Automatic unit-test discovery
  • Adding specialized extensions to the C language

One of the most popular uses of pycparser is in the cffi <https://cffi.readthedocs.io/en/latest/>_ library, which uses it to parse the declarations of C functions and types in order to auto-generate FFIs.

pycparser is unique in the sense that it's written in pure Python - a very high level language that's easy to experiment with and tweak. To people...

Read as markdown · JSON record · Source repository · Homepage

AI interpretation — verify before relying

AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page

pycparser is a pure-Python parser for C code that parses C99 and some C11 syntax into an abstract syntax tree, enabling programmatic analysis and transformation of C source without external dependencies.

Installs with zero runtime dependencies and no friction—a pure-Python wheel. Actively maintained with recent releases and 3559 GitHub stars; supports Python 3.10 through 3.14.

BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; suitable for most projects.

Usage

pip install pycparser

from pycparser import parse_file
ast = parse_file('example.c', use_cpp=True)

Requires a C preprocessor (cpp, gcc -E, or clang -E) in PATH or explicitly provided; most C code must be preprocessed before parsing.

Verdict: A mature, dependency-free C parser in active development with strong community adoption (top 100 PyPI). No known vulnerabilities and permissive licensing make it a reliable choice for C code analysis and tooling. The main gotcha is the preprocessor requirement—not a blocker, but a necessary step for real-world C code.

Needs verification

  • Whether the fake libc headers in utils/fake_libc_include are available post-install or only in the repository
  • Performance characteristics when parsing large C files or codebases
C code parser Pythonparse C source codeC syntax analysisC AST generatorC language parser librarystatic C code analysisC preprocessor integration

Similar packages