$npx skillfedfor your agent

pycparser

C parser in Python

Worth itPyPI Released Jan 20261.1B downloads / moBSD-3-ClausePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pycparser-3.0-py3-none-any.whl
v3.0 · released 2026-01-21 · Python >=3.10

Yes. pycparser is a mature, actively maintained library (top 20 PyPI package) with no external dependencies, permissive licensing, and proven real-world use in projects like cffi. Install it if you need to parse C code programmatically in Python. The main gotcha is the requirement for a C preprocessor in your environment, which is documented and straightforward to set up.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires a C preprocessor (cpp, gcc -E, or clang -E) in your PATH or explicitly provided to handle #include and #define directives in real C code.
  • Installation is straightforward with no external dependencies beyond Python itself.
  • The package is actively maintained with recent commits and supports modern Python versions from 3.10 onwards.

License · maintenance · safety

BSD-3-Clause (permissive) — Licensed under BSD-3-Clause (permissive), allowing use in both open-source and proprietary projects with minimal restrictions.

last release 2026-01-21 (205 days) · last repo commit 2026-07-29 · 3,559 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,107,200,067 downloads/mo, #20 on PyPI

Verify before relying

pip install pycparser

from pycparser import parse_file

ast = parse_file('example.c', use_cpp=True)
  • Whether fake_libc_include headers are available in the pip-installed package or only in the repository source.
  • Performance characteristics when parsing large C files with the provided fake headers.
Same gist for agents: .md · .json

What it is and what it does

pycparser is a pure-Python parser for the C language that converts C source code into an abstract syntax tree (AST) suitable for programmatic analysis and manipulation. It aims to support the full C99 standard with some C11 features, following the grammar from the C99 standard closely. The parser is designed to be easily integrated into applications that need to understand C code structure without external compilation dependencies.

The package requires preprocessed C code as input, meaning your code must first pass through a C preprocessor (cpp, gcc -E, or clang -E) to handle directives like #include and #define. pycparser provides a convenience function to automate this if a preprocessor is available in your PATH. It includes minimal fake standard library headers to allow parsing of typical C code that references stdio.h and similar headers, though these are not included in the pip package.

Use it for

  • Building C code analysis tools, static checkers, or obfuscators that need to understand C syntax and structure.
  • Creating front-ends for specialized C compilers or code generators that transform C into other languages.
  • Integrating C function and type declarations into Python via FFI libraries like cffi.
  • Automatic discovery and extraction of C code patterns for testing or documentation purposes.
  • Extending or modifying C language semantics by parsing and transforming the AST before code generation.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

pycparser is a mature, actively maintained library (top 20 PyPI package) with no external dependencies, permissive licensing, and proven real-world use in projects like cffi. Install it if you need to parse C code programmatically in Python. The main gotcha is the requirement for a C preprocessor in your environment, which is documented and straightforward to set up.

Install

pycparser on PyPI

Before you install

Installation is straightforward with no external dependencies beyond Python itself. The package is actively maintained with recent commits and supports modern Python versions from 3.10 onwards.

Requires a C preprocessor (cpp, gcc -E, or clang -E) in your PATH or explicitly provided to handle #include and #define directives in real C code.

License in practice

Licensed under BSD-3-Clause (permissive), allowing use in both open-source and proprietary projects with minimal restrictions.

Quickstart

pip install pycparser

from pycparser import parse_file

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

Verify before relying

  • Whether fake_libc_include headers are available in the pip-installed package or only in the repository source.
  • Performance characteristics when parsing large C files with the provided fake headers.

Package facts

LicenseBSD-3-Clause permissive
Python supportSupports the current Python release >=3.10
Install frictionLow. Pure-Python wheel
Runtime dependenciesNone
MaintenanceActively maintained 205 days since the last release
Last repo commit
First released
Downloads1,107,200,067 / month, #20 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
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

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

Tags

Capabilities
C parser Pythonparse C codeC syntax treeC language parsingC AST generatorC code analysisC preprocessor integration
Topics
c-parsingcode-analysisast-generation

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “C preprocessor integration”

  • pycparserpycparser is a C language parser written in pure Python that parses C…
  • pcppA pure Python implementation of a C99 preprocessor that can…
  • fyppFypp is a Python-powered preprocessor for Fortran that adds…

Give your agent the search over MCP, or paste the wish link into any chat.

Similar packages

cxxheaderparser With conditions
PyPI · Software Development · released Jul 2026

Parses C++ header files into Python data structures, extracting class definitions, functions, and modern C++ constructs without requiring a full AST or compiler validation.

BSD-3-Clausepure Python · 3.6+
365.7Kdownloads / mo
tree-sitter-c With conditions
PyPI · Linguistic · released Apr 2026

Provides a C language grammar for tree-sitter, enabling incremental parsing and syntax tree analysis of C code.

MITcompiled wheel · 3.10+
11.0Mdownloads / mo
pcpp With conditions
PyPI · Build Tools · released Oct 2021

A pure Python implementation of a C99 preprocessor that can preprocess C/C++ header files and source code, available both as a Python module and command-line tool.

However, the 2021 release date and aging maintenance status mean it may not track the latest C standards or receive active bug fixes—suitable for established…

BSD-3-Clausepure Pythonaging
791.6Kdownloads / mo
tree-sitter-python With conditions
PyPI · Linguistic · released Sep 2025

Provides a Python grammar for tree-sitter, enabling incremental parsing and syntax tree analysis of Python code.

However, the last release was 337 days ago—verify that the grammar version meets your Python syntax requirements before committing to it in production.

permissive licensecompiled wheel · 3.10+aging
9.6Mdownloads / mo
phply With conditions
PyPI · Text Processing · released Jan 2023

phply is a lexer and parser for PHP source code that generates abstract syntax trees, enabling PHP code analysis and conversion to other formats like JSON or Jinja2 templates.

BSD-3-Clausepure Pythonabandoned
183.8Kdownloads / mo
tree-sitter-ruby With conditions
PyPI · Linguistic · released Nov 2024

Provides a Ruby language grammar for tree-sitter, enabling incremental parsing and abstract syntax tree generation for Ruby code.

MITcompiled wheel · 3.9+
7.1Mdownloads / mo

See also Nuitka · luaparser · ctypesgen · tree-sitter-cpp