skillfed

dukpy

Simple JavaScript interpreter for Python

dukpy v0.6.0 610.6K downloads/30d#5,765 on PyPI532
Permissive license MIT Active released

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 dukpy

uv

uv add dukpy

poetry

poetry add dukpy

Installing 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

Development Status :: 3 - AlphaProgramming Language :: JavaScriptProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9

Tags

javascript interpreter pythontypescript compiler pythonjsx transpiler pythonless compiler pythonrun javascript from pythonjavascript evaluation pythonembedded js runtime
javascript-interpretertranspilerasset-pipeline

More Build Tools packages