python-minifier
Transform Python source code into it's most compact representation
Decision gist · record as of 2026-08-14
Yes, if you need to shrink Python source code for deployment or embedding. The package is stable (Production/Stable status), has no dependencies, and carries no security vulnerabilities. The main caveat is that minified code runs only on the Python version that performed the minification, so test carefully if you minify on a different version than your target runtime.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- The minifier's output is compatible only with the Python version running the minifier itself; minifying Python 3.11 code with a Python 3.12 interpreter produces Python 3.12-only output.
- Low friction: pure Python wheels for both Python 2 and 3, no runtime dependencies.
- Repository is active with recent commits and 718 stars; last release 226 days ago.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2025-12-31 (226 days) · last repo commit 2026-08-03 · 718 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 271,756 downloads/mo, #8,219 on PyPI
Alternatives
Verify before relying
pip install python-minifier
import python_minifier
with open('hello.py') as f:
minified = python_minifier.minify(f.read())
print(minified)- Whether minified code preserves all runtime semantics (e.g., introspection, dynamic imports, metaclass behavior)
- Performance overhead of the minification process itself on large codebases
- Compatibility guarantees when minifying code written for one Python version using an interpreter running a different version
What it is and what it does
python-minifier rewrites Python source code into a functionally identical but much smaller form by collapsing whitespace, shortening variable names, and simplifying syntax. It was originally built to embed AWS Lambda functions in CloudFormation templates, which have a 4 KiB size limit for inline code.
The tool works as both a command-line utility (pyminify) and a Python API. It supports Python 2.7 and Python 3.3 through 3.14, and the minified output is compatible with the same Python version that ran the minifier. There are no runtime dependencies, making installation straightforward.
Use it for
- Embed Python Lambda functions in AWS CloudFormation templates under the 4 KiB inline code limit
- Reduce deployment package size for serverless functions or edge computing environments
- Obfuscate source code for distribution when combined with other techniques
- Minimize Python code for resource-constrained environments or IoT devices
- Compress utility scripts or one-off tools before transmission or storage
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to shrink Python source code for deployment or embedding.
The package is stable (Production/Stable status), has no dependencies, and carries no security vulnerabilities. The main caveat is that minified code runs only on the Python version that performed the minification, so test carefully if you minify on a different version than your target runtime.
Install
python-minifier on PyPI
Before you install
Low friction: pure Python wheels for both Python 2 and 3, no runtime dependencies. Repository is active with recent commits and 718 stars; last release 226 days ago.
The minifier's output is compatible only with the Python version running the minifier itself; minifying Python 3.11 code with a Python 3.12 interpreter produces Python 3.12-only output.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install python-minifier
import python_minifier
with open('hello.py') as f:
minified = python_minifier.minify(f.read())
print(minified)
Verify before relying
- Whether minified code preserves all runtime semantics (e.g., introspection, dynamic imports, metaclass behavior)
- Performance overhead of the minification process itself on large codebases
- Compatibility guarantees when minifying code written for one Python version using an interpreter running a different version
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release !=3.0.*,!=3.1.*,!=3.2.*,<3.15,>=2.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 226 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 271,756 / month, #8,219 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development |
Evidence: python_minifier-3.2.0-py2-none-any.whl; python_minifier-3.2.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “python code minifier”
- python-minifierTransforms Python source code into compact, functionally equivalent…
- rjsminrjsmin minifies JavaScript code by removing unnecessary characters…
- rcssminRCSSmin minifies CSS by removing spaces, comments, and unnecessary…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also minify-html · jsmin · JSON_minify · htmlmin2 · mkdocs-minify-plugin · rjsmin · Flask-Minify · django-htmlmin · htmlmin · csscompressor