Metadata-Version: 2.4
Name: prompt-token-minifier
Version: 0.1.0
Summary: A lightweight tool to compress LLM prompts, minimize JSON schemas, and strip code comments to save tokens.
Author-email: Encephos <magiltraun@gmail.com>
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Prompt Token Minifier

A zero-dependency Python micro-tool to shrink your LLM prompts before sending them to the API. It saves tokens and reduces costs by:
- Minifying JSON schemas and examples inside Markdown blocks.
- Stripping comments (`//`, `#`, `/* */`) from code blocks.
- Collapsing redundant whitespaces and newlines.

## Installation

```bash
pip install prompt-token-minifier
```

## Usage

```bash
from prompt_token_minifier import minify_prompt

raw_prompt = """
You are a helpful assistant.
    
Here is the JSON schema you must follow:

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    }
  }
}

And some context code:

# This function calculates the sum
def add(a, b):
    return a + b
```


```python
print(minify_prompt(raw_prompt))
```

**Output:** *(Saves ~40% tokens depending on formatting)*

```bash
You are a helpful assistant.

Here is the JSON schema you must follow:

{"type":"object","properties":{"name":{"type":"string"}}}

And some context code:

def add(a, b):
    return a + b
```
