Lightweight token compression and JSON squashing for LLM prompts
Project description
TokToon
TokToon is a lightweight Python library designed to reduce Large Language Model (LLM) prompt token size without losing structure or intent.
It converts verbose text and JSON inputs into compact, schema-aware, and LLM-friendly formats—helping developers reduce token usage, improve latency, and lower API costs.
TokToon is deterministic, easy to integrate, and works with any LLM or agent framework.
Key Features
-
🔥 JSON Squasher
- Converts nested JSON into a compact, schema-based format
- Preserves structure while removing unnecessary syntax
- Ideal for passing structured data to LLMs
-
🎚️ Lossless and Lossy Modes
- Lossless mode preserves all fields and values
- Lossy mode enables aggressive compression for maximum token savings
-
🧠 LLM-Friendly Output
- Schema-first representation improves model reasoning
- Avoids heavy brackets, repetition, and verbosity
-
🐍 Lightweight & Dependency-Free
- No model or API dependencies
- Safe for production environments
Example
Input JSON
{
"friends": ["ana", "luis", "sam"],
"hikes": [
{ "id": 1, "name": "Blue Lake Trail", "distanceKm": 7.5 },
{ "id": 2, "name": "Ridge Overlook", "distanceKm": 9.2 }
]
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toktoon-0.1.2.tar.gz.
File metadata
- Download URL: toktoon-0.1.2.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09d688d23fe532d28b75f75a2bc18331953a9863ef514c9a9de8b1c174f8e134
|
|
| MD5 |
bd8e56e45ca7696cd7828f3883be3f9e
|
|
| BLAKE2b-256 |
0dd0f4af657b2fb85582d1f4440f10d0a10729d597697b73ab458f9a72dc9ba8
|
File details
Details for the file toktoon-0.1.2-py3-none-any.whl.
File metadata
- Download URL: toktoon-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1bdacb5a49a49f07f49362e98012e8c95bba6782d5586f81e345fb302fb5eb0
|
|
| MD5 |
c38ed083d6fac0193fca94dc98b18195
|
|
| BLAKE2b-256 |
65b17728e8d2b503ff6002d8a3a764eafdf6ce03f47a48c031d90e9b869856b3
|