Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toktoon-0.1.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toktoon-0.1.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

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

Hashes for toktoon-0.1.2.tar.gz
Algorithm Hash digest
SHA256 09d688d23fe532d28b75f75a2bc18331953a9863ef514c9a9de8b1c174f8e134
MD5 bd8e56e45ca7696cd7828f3883be3f9e
BLAKE2b-256 0dd0f4af657b2fb85582d1f4440f10d0a10729d597697b73ab458f9a72dc9ba8

See more details on using hashes here.

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

Hashes for toktoon-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b1bdacb5a49a49f07f49362e98012e8c95bba6782d5586f81e345fb302fb5eb0
MD5 c38ed083d6fac0193fca94dc98b18195
BLAKE2b-256 65b17728e8d2b503ff6002d8a3a764eafdf6ce03f47a48c031d90e9b869856b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page