Js2Py
JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python.
What it is and what it does
Js2Py is a pure-Python JavaScript interpreter and translator that lets you execute JavaScript code directly from Python. It works by translating JavaScript to Python bytecode, supporting the full ECMAScript 5.1 standard (except the 'with' statement) and experimental ES6 via Babel transpilation. You can evaluate inline JS expressions, define and call JS functions, access JS objects as Python-like wrappers, and import packages as Python modules.
The package is designed for scenarios where you need to run JavaScript logic without a Node.js runtime or browser. It has three lightweight dependencies (tzlocal, six, pyjsparser) and installs as a pure Python wheel, making it easy to deploy. However, it is dormant—last updated in late 2022—so it receives no active maintenance. ES6 support is experimental and slow. Edge cases in complex JavaScript may not translate correctly.
Use it for:
- Execute JavaScript snippets or algorithms from Python without spawning a separate runtime.
- Translate JavaScript files to Python for static analysis, testing, or integration into Python-only environments.
- Prototype or test JavaScript logic in a Python REPL without leaving the Python ecosystem.
- Build Python applications that need to interoperate with JavaScript logic or libraries.
- Access JavaScript object APIs and methods from Python code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Js2Py translates and executes JavaScript code in pure Python, supporting ECMAScript 5.1 and experimental ES6 via Babel transpilation, allowing you to run JS functions and libraries directly from Python.
Yes, if you need to run JavaScript from Python and can tolerate dormant maintenance. The pure-Python implementation and low install friction make it convenient for prototyping and light use. No, if you require active bug fixes, ES6 performance, or support for edge-case JavaScript patterns. Check the two known vulnerabilities (GHSA-h95x-26f3-88hr, PYSEC-2026-1476) before production use.
Install
js2py on PyPI
pip
pip install js2pyuv
uv add js2pypoetry
poetry add js2pyInstalling Js2Py
Before you install
Low friction: pure Python wheel with three lightweight runtime dependencies (tzlocal, six, pyjsparser). Maintenance is dormant—last release November 2022, last commit May 2024—so expect no active bug fixes or feature updates.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions, though you must include the license notice.
Quickstart
pip install js2py
import js2py
# Execute JavaScript inline
result = js2py.eval_js('2 + 3')
print(result) # 5
# Define and call a JS function
add = js2py.eval_js('function add(a, b) {return a + b}')
print(add(10, 20)) # 30
ES6 support requires importing Babel (a translated JS library), which takes approximately 15 seconds on first import; some edge cases (e.g. functions with many arguments, 'with' statement) are not supported.
Verify before relying
- Whether the two known vulnerabilities (GHSA-h95x-26f3-88hr, PYSEC-2026-1476) affect typical usage or are mitigated in version 0.74.
- Whether dormant maintenance status poses a risk for your use case—no active support for new JavaScript features or Python version compatibility issues.
- Performance characteristics when translating or executing large JavaScript files.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — tzlocal, six, pyjsparser |
| Maintenance | dormant — 1,377 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 837,010/month — #4,931 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | 2 — GHSA-h95x-26f3-88hr, PYSEC-2026-1476 |
Evidence: Js2Py-0.74-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
Js2Py-3.13Js2Py translates and executes JavaScript code…
permissive · top 15,000 on PyPI
pyjsparserParses JavaScript source code into an abstract…
permissive · top 15,000 on PyPI
dukpyDukPy is a JavaScript interpreter for Python…
permissive · top 15,000 on PyPI
groovyTranspiles Python functions to JavaScript,…
permissive · top 5,000 on PyPI
pscriptPScript compiles a Python subset to JavaScript,…
unclear · top 15,000 on PyPI
py-mini-racerEmbeds a modern V8 JavaScript engine in Python,…
permissive · top 5,000 on PyPI
CoffeeScriptCompiles CoffeeScript code to JavaScript from…
permissive · top 15,000 on PyPI
mini-racerEmbeds Google's V8 JavaScript engine in Python,…
permissive · top 5,000 on PyPI
esprima2Parses and tokenizes JavaScript code up to ECMA…
permissive · top 15,000 on PyPI
esprimaEsprima parses ECMAScript (JavaScript) source…
permissive · top 15,000 on PyPI