Skip to main content

pyobfus: the Python obfuscator

pyobfus Logo

Obfuscate Python before you ship it—and still debug what you shipped.

简体中文 · Product · Documentation · PyPI

PyPI version PyPI downloads Documentation Status License Python OpenSSF Best Practices DOI

pyobfus is a local-first, AST-based Python obfuscator for Python 3.9–3.14. It handles complete projects, keeps generated output portable, and can reverse-map protected production tracebacks for developers and AI coding agents. Community is Apache-2.0, has no file or line limits, and requires no trial.

What's new in v0.6.1: fixes two bugs where the build succeeded but the output failed when run. Directory builds broke from pkg import f as g (NameError), and single-file builds renamed parameters without updating keyword calls (TypeError, or arguments silently bound wrong). Parameter names are now kept by default; --no-preserve-param-names restores the old behavior with a warning. Rebuild, keep the new mapping, and rerun your tests; see the changelog.

Why pyobfus

Advantage What it means in practice
Complete Community edition Obfuscate real projects without a file/line cap or trial clock. Optional limits are your CI safety rails, not an upgrade gate.
Diagnosable protection Keep the private mapping and restore identifiers in production tracebacks without giving customers the original source.
Evidence, not a black box Scan, preview, verify syntax, retain provenance and compare reproducible build reports.
Portable and local-first Source stays local; Community emits ordinary cross-platform Python without a native build matrix.
Explicit security claims Tested, verified-once and advisory-only claims are separated; deterrents are not presented as irreversible security.

Quick start

pip install pyobfus

# Check compatibility, preview, then build
pyobfus --check src/
pyobfus src/ -o dist/ --dry-run --json
pyobfus src/ -o dist/ --save-mapping mapping.json --verify-syntax
# --verify-syntax only compiles the output; run your own tests against dist/

# Restore names when a production traceback arrives
pyobfus --unmap --trace error.log --mapping mapping.json

For framework presets, configuration discovery, packaging and verification, start at the task-oriented documentation.

Minimal example

Input:

def greet(name):
    message = f"Hello, {name}!"
    return message

print(greet("world"))

Run pyobfus input.py -o output.py. Representative Community output:

def I0(I1):
    I2 = f"Hello, {I1}!"
    return I2

print(I0("world"))

Both print Hello, world!. Generated identifiers can differ with input and configuration; verify the exact output with your own tests. Keep a mapping when you need to restore names from a shipped traceback.

Parameter names are preserved by default in every preset. Explicit --no-preserve-param-names or YAML preserve_param_names: false keeps legacy renaming with a warning: keyword calls may raise TypeError or silently bind incorrectly. Rebuild from original source and keep the new mapping with the new artifact; mapping numbers can change and old mappings cannot decode rebuilt output. Cross-file directory builds (the default) still preserve parameters; legacy --no-cross-file directory builds follow the option.

Features at a glance

Community includes name mangling with import rewriting across a project (directories also rename function locals; parameters and methods remain unchanged there; single files also rename methods and preserve parameters by default, see the guide), string and numeric transforms, framework-aware presets, config-aware pre-flight scanning, SARIF, structured dry-run, reverse traceback mapping, syntax verification, provenance, reproducible output and verifiable build reports.

Professional adds four kinds of commercial value:

  • Protection strength: AES encryption, control-flow flattening, dead-code injection, anti-debugging, Selective Opacity and sealing.
  • Protected assets: import strings, embedded data, Runtime String Vault and protected tracebacks.
  • Distribution control: device, expiry, run-count, platform and application-supplied-key policies.
  • Accountability: forensic watermarking and buyer-specific builds.

The durable classification rule is documented in the Community / Pro boundary policy.

🔌 Companion MCP server: pyobfus-mcp

Install the MCP server with no API key and no source upload:

uvx pyobfus-mcp
# or: pip install pyobfus-mcp

It exposes structured tools for scanning, configuration, protection, verification, preset explanation, tier recommendations and traceback mapping. See the MCP package guide and its registration in the official MCP Registry.

Agent and editor integrations

  • pyobfus-review and pyobfus-protect skills separate read-only review from build-producing work. See skills.
  • The VS Code extension provides inline risk diagnostics and traceback reversal; it is also on Open VSX.
  • zhurong2020/pyobfus-action@v1 runs scans or verified builds in GitHub Actions with SARIF support.
  • The stable JSON CLI includes reason codes and an ai_hint next action.
  • Agent-readable project facts are published in llms.txt, while contributor instructions live in AGENTS.md.

All Agent guidance is public and human-auditable. pyobfus does not serve hidden instructions or different facts based on User-Agent.

Configuration

Generate a starting configuration or use a named preset:

pyobfus --init src/
pyobfus src/ -o dist/ --preset django
pyobfus --list-presets

Community presets include safe, balanced, aggressive, fastapi, django, flask, pydantic, click, sqlalchemy and ml. See the documentation home and pyobfus --help for current options. Optional max_files and max_total_loc values are user-selected safety limits at every tier.

How do I debug an obfuscated crash with an AI assistant?

Build with --save-mapping mapping.json, keep that file private, then run:

pyobfus --unmap --trace error.log --mapping mapping.json

The restored identifiers can be read by you or an AI assistant without giving the customer your mapping or original source. --trace-marker can also stamp generated files with the exact recovery command.

Purchase Professional Edition

Professional Edition is $45 USD, one time—not a subscription. A five-day trial requires no registration or card:

pyobfus-trial start

The trial is an honor-system convenience control, not a security boundary. Visit the product and purchase page for current payment methods, refund terms and purchase steps. After purchase, use the license activation guide.

Runtime-backed Pro artifacts depend on the separately redistributable, pure-Python pyobfus-runtime package. Target machines do not need the complete proprietary builder or a licence key.

Security and limitations

Obfuscation raises the cost of inspection; it does not make client-side Python irreversible. Runtime-decrypted material can be observed by a determined attacker. Keep credentials and authorization decisions behind environment, secret-manager or server boundaries.

Comparison and deployment guides

Architecture and development

The product line separates the Apache-2.0 Core, proprietary Pro builder, redistributable runtime, MCP package, editor extension and GitHub Action. See:

Community and citation

Use GitHub Issues for bugs and Discussions for questions and ideas. Citation metadata is in CITATION.cff, with archival DOI 10.5281/zenodo.20846053.

Core is Apache-2.0; Professional implementation is proprietary. See LICENSE-NOTICE.md.

Metadata

Release files for pyobfus 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyobfus 0.6.1
File Size Uploaded
pyobfus-0.6.1.tar.gz 369.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyobfus 0.6.1
File Interpreter ABI Platform
pyobfus-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 623.7 kB

Release files / pyobfus-0.6.1.tar.gz

Download URL pyobfus-0.6.1.tar.gz
Size 369.6 kB
Tags Source
SHA-256 checksum
How to use checksums
27d5bc610385e3c286a3bdf3b951fffede6b652867a6ac26abe203bd9656d290
BLAKE2b-256 checksum
How to use checksums
cd473d5d695b149406fff070656aadba3358f1e43c4da4d14ad8f8890214cf67
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 Oct 10, 2026.

Transparency log

Release files / pyobfus-0.6.1-py3-none-any.whl

Download URL pyobfus-0.6.1-py3-none-any.whl
Size 254.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42296706b72ef576302752822a2d7183282ea83d7c5b471991d2d9c8a91a756b
BLAKE2b-256 checksum
How to use checksums
8c9b5debfef02c8c48e87cf1f55afab2939f98e790926c2a3f6b95a5d39f4bc3
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 Oct 10, 2026.

Transparency log

Release history Release notifications | RSS feed

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.30

2 release files

0.5.29

2 release files

0.5.28

2 release files

0.5.27

2 release files

0.5.26

2 release files

0.5.25

2 release files

0.5.24

2 release files

0.5.23

2 release files

0.5.19

2 release files

0.5.18

2 release files

0.5.17

2 release files

0.5.16

2 release files

0.5.15

2 release files

0.5.14

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

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