Skip to main content

Tree-sitter Chunker

PyPI Python 3.14+ Test Suite codecov License

Split source code into functions, classes, and other syntax units for code search, embeddings, and AI context. Tree-sitter provides the syntax tree; Chunker returns source content, line and byte spans, and context metadata.

Install

Development and 7.0.0 require Python 3.14 or newer. Python 3.12 and 3.13 are no longer supported (treesitter-chunker#599). CI, platform checks and release validation run on 3.14.

Published 6.0.0 retains Python 3.11 support. The main package is a universal Python wheel.

pip install treesitter-chunker

The default parser stack uses Tree-sitter 0.26 and language-pack 1.20. Parser libraries download on first use and are cached by pack version and platform. The supported Linux wheel path requires glibc 2.34 or newer. For offline use, prefetch the languages you need while online:

python -c "import tree_sitter_language_pack as p; p.prefetch(['python', 'javascript', 'typescript'])"

See packaging and parser integrity for platform limits, offline custody, and release procedures. Debian, RPM, and Homebrew packages are currently suspended.

Optional extras include viz for visualization and advanced for additional query dependencies. Graphviz visualization also requires the system dot executable. The api extra installs REST API dependencies; the server under api/ runs from a source checkout and is not included in the main wheel.

Chunk a file or source text

from chunker import chunk_file, chunk_text

chunks = chunk_file("app.py", language="python")
for chunk in chunks:
    print(chunk.node_type, chunk.start_line, chunk.end_line)
    print(chunk.content)

source = "def greet(name):\n    return f'Hello, {name}'\n"
chunks = chunk_text(source, language="python", file_path="greet.py")

Pass a stable file_path when chunking text if you persist chunk identities. See the chunk identity contract and Boundary IR specification for identity, determinism, and relationship semantics.

The CLI can return JSON for use from other languages:

treesitter-chunker chunk app.py --lang python --json
printf 'def greet():\n    return "hello"\n' | treesitter-chunker chunk --stdin --lang python --json
treesitter-chunker boundary app.py --lang python --pretty
treesitter-chunker languages
treesitter-chunker --help

To check the installed version:

python -c "from importlib.metadata import version; print(version('treesitter-chunker'))"

Language support

The pinned language pack contains 371 parsers: 370 pass the bounded load gate, while COBOL is disabled after a native parser hang. Loading a parser does not establish useful chunk extraction. The committed coverage report records 28 extraction-verified languages and 12 languages with deterministic Boundary IR golden fixtures.

See the language coverage report for the per-language results and remaining extraction gaps.

BAML

Install the optional companion grammar for structural .baml chunking:

pip install 'treesitter-chunker[baml]'
treesitter-chunker chunk example.baml --json

The extra pins treesitter-chunker-baml-grammar==0.1.0. It uses BoundaryML's official grammar with a temporary overlay for BAML 0.20.1 backtick prompts. Published 0.1.0 has cp311-abi3 wheels for Linux glibc x86_64/aarch64, macOS x86_64/arm64, and Windows x86_64. The companion source now builds cp312-abi3 wheels and tests them on Python 3.12 and 3.14 for a future release. Source installs require a C compiler.

Without the extra, main CLI BAML inputs give installation guidance and status 1; implicit ZeroConfigAPI file chunking falls back to text, and automatic symbol and Boundary repository scans skip BAML. Malformed BAML fails before returning structural chunks. See the companion grammar README.

Documentation

Development

git clone https://github.com/Consiliency/treesitter-chunker.git
cd treesitter-chunker
uv sync --locked --all-extras
uv run --locked --with toml --all-extras python scripts/run_ci_smoke.py

CONTRIBUTING.md describes local validation, platform checks, and Boundary IR changes. Coverage work remains in progress under treesitter-chunker#69; the Codecov badge reports the CI measurement and is not a claim that the full package meets a percentage target.

Report bugs through GitHub issues. Licensed under MIT.

Metadata

Release files for treesitter-chunker 7.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for treesitter-chunker 7.0.0
File Size Uploaded Provenance Actions
treesitter_chunker-7.0.0.tar.gz 1.7 MB With provenance Details for treesitter_chunker-7.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for treesitter-chunker 7.0.0
File Interpreter ABI Platform Actions
treesitter_chunker-7.0.0-py3-none-any.whl Python 3 none any Details for treesitter_chunker-7.0.0-py3-none-any.whl

Total release size: 2.6 MB

Release files / treesitter_chunker-7.0.0.tar.gz

Download URL treesitter_chunker-7.0.0.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
c8dde63a36c9de38a9428b689ae2af54230066b857cf0dd01eaa7462a2e86902
BLAKE2b-256 checksum
How to use checksums
88f806ef4d1d59d85cfd27d60ec7ee644e7c0b9bfafddf0253d75d47706d37e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / treesitter_chunker-7.0.0-py3-none-any.whl

Download URL treesitter_chunker-7.0.0-py3-none-any.whl
Size 945.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c15277fd9ded58a781dbe3a1a1e9d06032736d06df2df17c7ddb7861dc788a5
BLAKE2b-256 checksum
How to use checksums
42ffe8206ccba0344ac6777d772d1adff64563d31b6ed4d6365dfbe48645cd9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for treesitter-chunker 7.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for treesitter_chunker-7.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

7.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page