Skip to main content

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

pip install prompt-token-minifier

Usage

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
print(minify_prompt(raw_prompt))

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

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

Metadata

Release files for prompt-token-minifier 0.1.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 prompt-token-minifier 0.1.0
File Size Uploaded Provenance Actions
prompt_token_minifier-0.1.0.tar.gz 4.2 kB With provenance Details for prompt_token_minifier-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prompt-token-minifier 0.1.0
File Interpreter ABI Platform Actions
prompt_token_minifier-0.1.0-py3-none-any.whl Python 3 none any Details for prompt_token_minifier-0.1.0-py3-none-any.whl

Total release size: 8.4 kB

Release files / prompt_token_minifier-0.1.0.tar.gz

Download URL prompt_token_minifier-0.1.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0b771621d85004aded0aefa6553986306d0c103aef4afa590a64c5e2fdc2c963
BLAKE2b-256 checksum
How to use checksums
c467ae90a6cc128df147bfeb21e7fd435676ea12cb6f200ccff65cbb1f6050fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.

Transparency log

Release files / prompt_token_minifier-0.1.0-py3-none-any.whl

Download URL prompt_token_minifier-0.1.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f9667010bd985ee6bfdb7df62710d86ec3126f5515304a416c8d98b630ba381
BLAKE2b-256 checksum
How to use checksums
dc8acd5c613fc1ef75d5131cd755b59af79196542178869c8a259fbc94198fff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.

Transparency log

Security for prompt-token-minifier 0.1.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for prompt_token_minifier-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.

Transparency log

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

0.1.0 This release

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