tree-sitter-cpp
C++ grammar for tree-sitter
What it is and what it does
tree-sitter-cpp is a C++ language grammar for the tree-sitter incremental parsing framework. It translates C++ source code into syntax trees that can be traversed and analyzed programmatically. The package ships as prebuilt binary wheels for major platforms, avoiding compilation on installation.
The grammar enables use cases like code analysis, refactoring tools, linters, and IDE features that need to understand C++ structure. It integrates with tree-sitter's ecosystem and follows the C++ BNF specification, supporting incremental updates when code changes rather than reparsing from scratch.
Use it for:
- Build code analysis and linting tools that need to parse and inspect C++ syntax trees.
- Implement IDE features like syntax highlighting, code navigation, and refactoring for C++ editors.
- Analyze C++ codebases to extract metrics, dependencies, or patterns without invoking a full compiler.
- Create documentation generators or code transformation tools that operate on C++ ASTs.
- Develop static analysis or security scanning tools that examine C++ code structure.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a C++ language grammar for tree-sitter, enabling incremental parsing and syntax tree generation for C++ code.
Yes, if you need C++ parsing within a Python application and are already using or planning to use tree-sitter. The permissive MIT license, active maintenance, and prebuilt wheels for common platforms make it a low-friction choice. No known security vulnerabilities. Verify that your use case aligns with tree-sitter's incremental parsing model and that you have or will install the core tree-sitter Python bindings separately.
Install
tree-sitter-cpp on PyPI
pip
pip install tree-sitter-cppuv
uv add tree-sitter-cpppoetry
poetry add tree-sitter-cppInstalling tree-sitter-cpp
Before you install
Medium install friction due to binary wheels for multiple platforms (macOS, Linux, Windows, ARM); prebuilt binaries available for Python 3.9+ reduce compilation overhead. Repository is actively maintained with recent commits.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install tree-sitter-cpp
from tree_sitter_cpp import language
parser = language.parser()
tree = parser.parse(b'int main() { return 0; }')
Requires Python 3.9 or later; prebuilt wheels available for common platforms but may require compilation on unsupported architectures.
Verify before relying
- Whether the package provides direct parsing APIs or requires a separate tree-sitter Python binding to be installed alongside it.
- Performance characteristics and memory overhead for parsing large C++ files or codebases.
- Completeness of C++ standard coverage (C++11, C++17, C++20, etc.) in the grammar.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 641 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,786,023/month — #2,231 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tree_sitter_cpp-0.23.4-cp39-abi3-macosx_10_9_x86_64.whl; tree_sitter_cpp-0.23.4-cp39-abi3-macosx_11_0_arm64.whl; tree_sitter_cpp-0.23.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; tree_sitter_cpp-0.23.4-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; tree_sitter_cpp-0.23.4-cp39-abi3-musllinux_1_2_x86_64.whl; tree_sitter_cpp-0.23.4-cp39-abi3-win_amd64.whl; tree_sitter_cpp-0.23.4-cp39-abi3-win_arm64.whl
Keywords: incremental, parsing, tree-sitter, cpp
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
tree-sitter-javaProvides a Java language grammar for…
permissive · top 5,000 on PyPI
cxxheaderparserParses C++ header files into Python data…
permissive · top 15,000 on PyPI
tree-sitter-pythonProvides a Python grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-cProvides a C language grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-phpProvides a PHP language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-goProvides a Go language grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-kotlinProvides a Kotlin language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-c-sharpProvides a C# language parser for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-cssProvides a CSS grammar parser for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-jsonProvides a JSON grammar parser for tree-sitter,…
permissive · top 5,000 on PyPI