dukpy
Simple JavaScript interpreter for Python
What it is and what it does
DukPy embeds a JavaScript interpreter in Python, allowing you to execute JavaScript code directly from Python and get results back as JSON-serializable objects. It also includes built-in transpilers for TypeScript, JSX, and LESS, making it useful for asset pipelines and build workflows that need to run on the server side without spawning external processes.
The package supports both one-off code evaluation via `evaljs()` and persistent interpreter instances via `JSInterpreter` for scenarios where bootstrap cost matters. It can load JavaScript modules via `require()` and run ES modules or CommonJS files. Since version 0.6.0, it has no external runtime dependencies—the interpreter is bundled—and supports Python 3.9 through 3.14 across multiple platforms.
Use it for:
- Transpile TypeScript or JSX on the server during build or request time without invoking external tools.
- Evaluate dynamic JavaScript expressions passed as configuration or user input and return results to Python.
- Compile LESS stylesheets as part of a Python-based asset pipeline or web framework.
- Run JavaScript unit tests or validation logic from within a Python test suite or CI workflow.
- Load and execute npm modules in a Python application without a separate Node.js process.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
DukPy is a JavaScript interpreter for Python that runs JavaScript code and transpiles TypeScript, JSX, and LESS without requiring an external runtime.
Yes, if you need to run JavaScript or transpile TypeScript/JSX/LESS from Python without external dependencies. The package is actively maintained, has no known vulnerabilities, and supports current Python versions. Install friction is moderate but manageable. Not recommended if you need high-performance JavaScript execution or have complex npm ecosystem dependencies beyond what DukPy's loader can resolve.
Install
dukpy on PyPI
pip
pip install dukpyuv
uv add dukpypoetry
poetry add dukpyInstalling dukpy
Before you install
Medium install friction due to compiled wheels for multiple platforms and Python versions (3.9–3.14). The package is actively maintained with a recent release (22 days old) and no external runtime dependencies, making it straightforward to deploy once installed.
License in practice
Licensed under MIT, a permissive license that allows commercial and private use with minimal restrictions.
Quickstart
pip install dukpy
import dukpy
# Evaluate JavaScript
result = dukpy.evaljs("var o = {'value': 5}; o['value'] += 3; o")
print(result) # {'value': 8}
# Transpile TypeScript
ts_code = "class Greeter { constructor(public greeting: string) {} }"
js_code = dukpy.typescript_compile(ts_code)
# Transpile JSX
jsx_result = dukpy.jsx_compile('var react_hello = Hello, world!;')
# Compile LESS
less_result = dukpy.less_compile('.class { width: (1 + 1) }')
Verify before relying
- Whether the package's performance is suitable for production workloads involving large or frequent JavaScript evaluations.
- Compatibility and integration details with WebAssets pipelines beyond the documented examples.
- Whether npm package installation via dukpy.install_jspackage is fully functional (description excerpt cuts off mid-sentence).
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 22 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 610,562/month — #5,765 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dukpy-0.6.0-cp310-cp310-macosx_10_9_x86_64.whl; dukpy-0.6.0-cp310-cp310-macosx_11_0_arm64.whl; dukpy-0.6.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; dukpy-0.6.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; dukpy-0.6.0-cp310-cp310-musllinux_1_2_aarch64.whl; dukpy-0.6.0-cp310-cp310-musllinux_1_2_x86_64.whl; dukpy-0.6.0-cp310-cp310-win32.whl; dukpy-0.6.0-cp310-cp310-win_amd64.whl; dukpy-0.6.0-cp311-cp311-macosx_10_9_x86_64.whl; dukpy-0.6.0-cp311-cp311-macosx_11_0_arm64.whl; dukpy-0.6.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; dukpy-0.6.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; dukpy-0.6.0-cp311-cp311-musllinux_1_2_aarch64.whl; dukpy-0.6.0-cp311-cp311-musllinux_1_2_x86_64.whl; dukpy-0.6.0-cp311-cp311-win32.whl; dukpy-0.6.0-cp311-cp311-win_amd64.whl; dukpy-0.6.0-cp312-cp312-macosx_10_13_x86_64.whl; dukpy-0.6.0-cp312-cp312-macosx_11_0_arm64.whl; dukpy-0.6.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; dukpy-0.6.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Keywords: javascript, compiler, jsx, typescript
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
jsiijsii is a Python runtime client that enables…
permissive · top 5,000 on PyPI
pscriptPScript compiles a Python subset to JavaScript,…
unclear · top 15,000 on PyPI
quickjs-rsExecutes JavaScript code inside a WebAssembly…
permissive · top 15,000 on PyPI
Js2PyJs2Py translates and executes JavaScript code…
permissive · top 5,000 on PyPI
quickjsWraps the QuickJS C library to execute…
unclear · top 5,000 on PyPI
Js2Py-3.13Js2Py translates and executes JavaScript code…
permissive · top 15,000 on PyPI
mini-racerEmbeds Google's V8 JavaScript engine in Python,…
permissive · top 5,000 on PyPI
denoPackages and distributes Deno (a…
permissive · top 15,000 on PyPI
lesscpyCompiles LESS stylesheets to CSS using Python,…
permissive · top 15,000 on PyPI
bfiA pure-Python interpreter for Brainfuck that…
permissive · top 15,000 on PyPI