ctxsplit
Split long text into overlapping chunks for LLM context windows or RAG. Breaks on paragraphs first, then sentences (including Arabic ؟), then words, and carries a short overlap into the next chunk so context is not lost. Pure Python, no dependencies.
from ctxsplit import split
chunks = split(open("book.txt").read(), max_chars=2000, overlap=200)
python -m ctxsplit book.txt --max-chars 1500 --overlap 150 # JSON list of chunks
Sizes are in characters. Divide by about 4 for a rough English token count (see tokenwise).
Install
pip install ctxsplit
Or copy ctxsplit.py into your project, it has no dependencies.
Test
python -m pytest
MIT licensed.
Metadata
Release files for ctxsplit 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ctxsplit-0.1.0.tar.gz | 3.3 kB | With provenance | Details for ctxsplit-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ctxsplit-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for ctxsplit-0.1.0-py3-none-any.whl |
Total release size: 7.1 kB
Release files / ctxsplit-0.1.0.tar.gz
| Download URL | ctxsplit-0.1.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11df6804bba1100a1460adb754295ae4849566f3d3a46ac61d4c82cc1bc0509e
|
|
BLAKE2b-256 checksum How to use checksums |
01a6ab63dcaf3550e0128903cd86241512586271eb24fadc8b989a87daa04b5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 28, 2026.
Transparency logRelease files / ctxsplit-0.1.0-py3-none-any.whl
| Download URL | ctxsplit-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6bdfb0866078a495eb1e243acfd29c98cc4c6f1d211db1c42c88db1b803e9ac0
|
|
BLAKE2b-256 checksum How to use checksums |
566a463a891e46eae4c650a3fbf241151a061254a41e379ba6fe59c77a67c2ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 28, 2026.
Transparency logSecurity for ctxsplit 0.1.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.
Attestation for ctxsplit-0.1.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 28, 2026.
Transparency logA 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.