1. License
“Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met”
BSD 3-Clause allows commercial use; do not use the author's or contributors' names to promote your product.
github.com/eliben/pycparser/blob/main/LICENSE3. Used by agents' projects
Dependency in 39 public GitHub projects set up for AI coding agents that we scanned (0.6%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error
What pycparser does
pycparser is a free Python library that reads C source code and turns it into a tree of parts a script can walk, like every function, type and parameter. It is for tools that check, document or change C code. Most people get it without asking, because CFFI uses it.
What people build with it
List the functions in a C header
Your script reads a library's header file and prints every function with its parameters, for docs or a wrapper.
Check C code for house rules
A small checker flags code that breaks your team's rules, such as a banned function or a missing return type, before review.
Find tests in C projects
Scan C test files for functions named test_* and build the list your test runner calls.
Generate bindings for other languages
Read a header once and write matching declarations for Python, Rust or JavaScript code that calls the same C library.
Rewrite C code automatically Idea
Change the tree, for example rename a function everywhere, and print it back as C source with the built-in code generator.
Teach how C declarations read Idea
Show students or teammates how a confusing declaration like a pointer to an array of functions breaks down, part by part.
pycparser popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How pycparser is used
- pycparser is a dependency in 39 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (2.4% of the 1,623 Python ones), #10 of 70 in languages, types and runtimes.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,024; those are left out of every share on this page.
- The most used alternative in our scan is Cython (4 projects).
- Projects that use it most often also use CFFI (97.4%), Pydantic (94.9%), Click (89.7%).
By coding agent
Often used with
More about pycparser
More in Languages, types and runtimes
Alternatives
pycparser This page
Pick libclang when you need the real Clang compiler's view of the code, including C++, and can install LLVM.
Pick the Tree-sitter C grammar for editors and code search that must cope with half-written code and skip the preprocessor.
Pick PLY when you want to build a parser for your own small language rather than read C.
Compiles Python to C for performance-critical code and C extensions.
Get started
Tell your AI assistant
“Use pycparser (pin pycparser==3.12, Python 3.11+) to parse this C header with parse_file(path, use_cpp=True) and a c_ast.NodeVisitor, then list every function with its parameters; run the C preprocessor first, never feed raw files with include lines or comments.”
Install it with pip into your project's environment; it has no other packages of its own.
> pip install pycparserParse a short piece of C directly, or a real file through the C preprocessor with parse_file(use_cpp=True).
from pycparser import CParser, parse_file ast = parse_file( "example.c", use_cpp=True, cpp_args=["-std=c23"], parser=CParser(dialect="c23"), )Walk the tree with a NodeVisitor subclass and pick the parts you need.
Mistakes to avoid
In our run the raw header failed with "ParseError - :1:1: Directives not supported yet"; through cpp it parsed.
The real system headers are full of compiler extensions; the fake ones hold only what parsing needs.
The fake headers are not part of the pip package.
C23 support is off by default because its new keywords clash with older code.
pycparser 3.12 declares Python 3.11 as the minimum.
Questions
Why did I get pycparser without installing it?
CFFI uses pycparser to read C declarations, so installing CFFI (or a package built on it) brings it in.
Does it need anything else installed?
No other Python packages. For real files you also need a C preprocessor such as cpp, gcc -E or clang -E on your PATH.
Did version 3 change how I use it?
Version 3.00 rewrote the parser by hand and dropped the PLY dependency; the release notes say the same tree comes out.
Can it read C23 code?
Yes, when you create the parser with dialect="c23" and pass -std=c23 to the preprocessor yourself.
Can I use it in a commercial product?
Yes. The BSD 3-Clause license allows it if you keep the notice and do not use the author's name for promotion.