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.1.tar.gz (3.4 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.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file toktoon-0.1.1.tar.gz.

File metadata

  • Download URL: toktoon-0.1.1.tar.gz
  • Upload date:
  • Size: 3.4 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.1.tar.gz
Algorithm Hash digest
SHA256 4ba1f550eb86ed868b35e1a3e2a0cca355cb824384ff854a6954ebe51a40c7fc
MD5 cbfcc35319b7eff546accf0f5480b4bc
BLAKE2b-256 c879ddec14769a50bdfbe07da4c207fa1466bfa2a4a787b0fde817815829e8c9

See more details on using hashes here.

File details

Details for the file toktoon-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: toktoon-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b1dd8cf3ab1ba07ee1522e458142bdf7a7399d1dca504d17bb6cb10c898e423
MD5 b25c353a228f1f4d31214cb9b44e2142
BLAKE2b-256 1b034d23ce2e2f5680b0a7d5123900639576d4cf953a36c19f529fc033b60fc4

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