Skip to main content

tokzip

Python 3.9+ MIT License Zero required dependencies v1.0.0

Clean up chats, source code, JSON, logs, or entire folders before adding them to an AI prompt. The compressor runs fully offline with Python 3.9+.

This is a finished personal tool shared as-is. It may receive occasional updates.

Русская версия

Quick start

Download and unpack the repository, then run these commands in a terminal from that folder.

python -m tokzip notes.md --no-clip
python -m tokzip ./project --brutal -o bundle.txt --no-clip
python -m tokzip --gui

On Windows, tokzip.cmd accepts the same arguments. Running the module, launcher, or compress.py without arguments opens the GUI when launched from a terminal. The GUI uses Tk if it is available in your Python installation.

For the installed tokzip command, run python -m pip install . from the unpacked folder. This uses setuptools at build time. You can use the commands above directly from source with Python alone.

Before → after

Input Output in max
## Inventory Inventory
**Ready** to process. Ready to process.
Mode What it changes
high Tidies whitespace, keeps comments and formatting, and looks for clear dictionary savings.
max Default. Removes Markdown emphasis, comments in recognized code, and Python docstrings. Packs repeated lines and finds more dictionary candidates.
brutal Also removes emoji from prose and chat timestamps. Packs directory trees and repeated document blocks.

Chat code fences keep their line breaks and indentation. JSON compaction keeps string contents and number spellings. Code cleanup outside Python uses language-specific patterns and preserves recognized multiline literals.

CLI and local expansion

python -m tokzip --stdin --stdout < input.txt
python -m tokzip - --stdout --lang ru < input.txt
python -m tokzip notes.md --dry-run
python -m tokzip --expand bundle.txt --stdout

In PowerShell, use Get-Content -Raw input.txt | python -m tokzip --stdin --stdout to pipe a file.

--stdout sends just the result to stdout and reports statistics on stderr. --dry-run reports statistics without writing files or using the clipboard. File output copies the file to the clipboard when the OS supports it. Use --no-clip to skip copying or --clip-text to copy the text. Run python -m tokzip --help for all flags.

--expand (also --decompress) expands v1.0 output into the cleaned text. It restores dictionary phrases, line and block repeats, shared blocks, and compact trees. Cleanup itself can discard comments, formatting, chat timestamps, and other content. Use the original files when you need their exact contents.

Directory scans skip sensitive names such as .env, private keys, and credential JSON files. They also skip symbolic links and known binary files. To add project-specific filters, put a UTF-8 .compressignore in the scanned directory. Use one case-sensitive glob per line, such as *.log, drafts/**/private-*.md, or generated/ for directories. Blank lines and lines beginning with # are ignored. --include-secrets overrides the built-in sensitive-name filter. Explicitly selected files are read directly. Review a bundle before sharing it.

Saved results go to ./compressed_files/ in your working directory unless you pass -o. The OS determines the user log directory.

OS Log folder
Windows %LOCALAPPDATA%\tokzip\logs
macOS ~/Library/Logs/tokzip/
Linux ~/.local/state/tokzip/logs/ or $XDG_STATE_HOME/tokzip/logs/

Optional features

Install ".[tokens]" to use exact o200k_base token counts, ".[dnd]" for drag-and-drop in Tk, or ".[full]" for both, using python -m pip install followed by the extra. For exact counts, run this command once while connected to populate the local tokenizer cache.

python -c "import tiktoken; tiktoken.get_encoding('o200k_base')"

The compressor reads only the local vocabulary cache. When the tokenizer or its cache is unavailable, it reports estimated counts.

Measured examples

Measured on Python 3.14.3 by running the CLI on synthetic UTF-8 files. The samples were a 40-line maintenance log, 28 Python functions with comments and docstrings, and four copies of the same Unicode directory tree. Byte counts below are from the exact-token runs.

Sample Mode UTF-8 bytes o200k_base tokens Stdlib estimate
Repeated log high 4,079 → 945 599 → 301 999 → 273
Commented Python max 4,720 → 1,017 896 → 297 1,538 → 468
Repeated directory tree brutal 5,367 → 814 1,903 → 342 1,931 → 385

Previews

GUI showing a compressed maintenance log

CLI dry run on the same sample

Run the local test suite with python -m unittest discover.

Changelog · Pre-Git history · MIT license

Metadata

Release files for tokzip 1.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 tokzip 1.0.0
File Size Uploaded Provenance Actions
tokzip-1.0.0.tar.gz 40.3 kB Without provenance Details for tokzip-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tokzip 1.0.0
File Interpreter ABI Platform Actions
tokzip-1.0.0-py3-none-any.whl Python 3 none any Details for tokzip-1.0.0-py3-none-any.whl

Total release size: 83.8 kB

Release files / tokzip-1.0.0.tar.gz

Download URL tokzip-1.0.0.tar.gz
Size 40.3 kB
Tags Source
SHA-256 checksum
How to use checksums
809678571e3a04078742f4b7ec7c61b49ec76b22500c426222c5bb386e2880a4
BLAKE2b-256 checksum
How to use checksums
49eac91c134ae9d24170511fd896756a39fff6007b128a00444fab8d9777c016
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / tokzip-1.0.0-py3-none-any.whl

Download URL tokzip-1.0.0-py3-none-any.whl
Size 43.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9787386989d09b3663b2b402531d8c47c7d47c13bd7009a2b1532f96591c9b9f
BLAKE2b-256 checksum
How to use checksums
356905a872cdd3577c96f03b96df691e21a1eb00781a58f3fa424d8e326eb772
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for tokzip 1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

1.0.0 This release

2 release files No 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