🌐
GitHub
github.com › PiotrDabkowski › Js2Py
GitHub - PiotrDabkowski/Js2Py: JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python🚀 Try it online:
JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python🚀 Try it online: - PiotrDabkowski/Js2Py
Starred by 2.6K users
Forked by 278 users
Languages   JavaScript 65.1% | Python 34.9%
🌐
GitHub
github.com › PB2204 › Convert-JavaScript-To-Python
GitHub - PB2204/Convert-JavaScript-To-Python: Using this NPM package you can convert your JavaScript code to Python and then use it . · GitHub
Using this NPM package you can convert your JavaScript code to Python and then use it . - PB2204/Convert-JavaScript-To-Python
Starred by 33 users
Forked by 2 users
Languages   JavaScript
Discussions

Conversion from JavaScript to Python code? - Stack Overflow
Is there a relatively quick program out there to accomplish at least the basics of this? Just a few regexes? I'm willing to do some manual conversion, but this is a pretty big set of scripts. More on stackoverflow.com
🌐 stackoverflow.com
Converting Python to Javascript
Honestly, "translation" tools are usually bad. It would probably be better for you and your project to learn the language and do it yourself :) More on reddit.com
🌐 r/Python
7
0
January 30, 2018
ASK HN: How to engineer a JavaScript to Python migration?
There are some jobs that contain rather simple JavaScript snippets, and I was trying to design a first prototype that simply takes the JS parts and runs them in a transpiler · In this respect, I found a couple of packages that could be leveraged: - js2py: https://github.com/PiotrDabkowski/Js2Py ... More on news.ycombinator.com
🌐 news.ycombinator.com
40
22
March 18, 2025
I just gave ChatGPT 200+ lines of JavaScript code and asked it to translate the code into Python. The code parses text using regular expressions. It was complex. 2 minutes later and I had Python code that worked flawlessly. This thing just saved me a couple of days of work.
Was this post also created by ChatGPT? More on reddit.com
🌐 r/programming
31
9
January 6, 2023
🌐
GitHub
github.com › JonBoynton › JSConvert
GitHub - JonBoynton/JSConvert: A utility for transpiling Javascript(ES6) source code to Python and other languages. · GitHub
A utility for transpiling Javascript(ES6) source code to Python and other languages. - JonBoynton/JSConvert
Author   JonBoynton
🌐
GitHub
github.com › timothycrosley › jiphy
GitHub - timothycrosley/jiphy: Your client side done in a jiphy. Python to JavaScript 2-way converter.
Converts in both directions (JavaScript -> Python, Python -> JavaScript). Allows intermixing of code. You can add a Python function to a JavaScript file and then convert it all to JavaScript.
Starred by 586 users
Forked by 73 users
Languages   Python 98.7% | Shell 1.3% | Python 98.7% | Shell 1.3%
🌐
GitHub
github.com › int3 › js2py
GitHub - int3/js2py: A Javascript-to-Python translation assistant.
A Javascript-to-Python translation assistant. It does a simple translation from Javascript to Python (as detailed below).
Author   int3
🌐
GitHub
github.com › PB2204 › Convert-JavaScript-To-Python › tree › main › js-to-python-converter
Convert-JavaScript-To-Python/js-to-python-converter at main · PB2204/Convert-JavaScript-To-Python
Using this NPM package you can convert your JavaScript code to Python and then use it . - Convert-JavaScript-To-Python/js-to-python-converter at main · PB2204/Convert-JavaScript-To-Python
Author   PB2204
🌐
Gitloop
gitloop.com › tool › javascript-to-python
JavaScript to Python Code Converter
⬇️ Paste or enter your JavaScript code and easily convert it to Python with a single click.Try GitLoop — The AI That Knows Your Entire Codebase
🌐
GitHub
github.com › quadramadery › js2py
GitHub - quadramadery/js2py: Convert JavaScript to Python
Convert JavaScript to Python. Contribute to quadramadery/js2py development by creating an account on GitHub.
Starred by 9 users
Forked by 6 users
Languages   JavaScript 100.0% | JavaScript 100.0%
Find elsewhere
🌐
GitHub
github.com › tvst › jsbuilder
GitHub - tvst/jsbuilder: Convert Python code to JavaScript strings, just by decorating it with @js! · GitHub
Now you can just call str(js_code) or print(js_code) to see the JavaScript version of that code: (Note: the code below has been pretty-printed for clarity) function sum_and_check_if_42(a, b) { var c = (a + b); if (c === 42) { return true } else { return false } }; result = sum_and_check_if_42(10, 30); console.log("Is it 42?", result) Here's some code that was copy/pasted directly from the D3 documentation, then converted to Python:
Starred by 53 users
Forked by 4 users
Languages   Python 96.5% | Makefile 3.5%
🌐
Xpdevs
xpdevs.github.io › JS2PY
JS2PY - JavaScript to Python Converter
Simply add it to your project, and you’ll be able to seamlessly convert JavaScript into Python code. ... To use JS2PY in your own web project, simply add the following line of code inside the <head> tag of your HTML document: <script src="https://xpdevs.github.io/JS2PY/data/data.json"></script>
🌐
GitHub
github.com › metapensiero › metapensiero.pj
GitHub - metapensiero/metapensiero.pj: Javascript for refined palates: a Python 3 to ES6 Javascript translator · GitHub
This will convert the input string with all the extensions enabled (comparable to adding the '-5' option) and so it will take some time because of BabelJS load times. This offers many ways to test the framework, both the string conversion and the evaluation using the embedded JavaScript interpreter are very handy. For example: $ pj -s '"foo" if True else "bar"' (true ? "foo" : "bar"); ... You can use metapensiero.pj in python code as well.
Starred by 900 users
Forked by 72 users
Languages   Python 94.4% | JavaScript 3.3% | Nix 2.1% | Makefile 0.2%
🌐
GitHub
github.com › gee-community › ee-js-to-python-syntax
GitHub - gee-community/ee-js-to-python-syntax: Simplistic conversion of earthengine JavaScript to Python syntax.
Very preliminary proof of concept for a package that enables easy conversion of earth engine JavaScript examples to Python syntax. Potentially jiphy is usful, although it seems to be un-maintained. So far RegEx is used to convert general JS syntax to Python equilvilent.
Starred by 18 users
Forked by 8 users
Languages   Jupyter Notebook 74.2% | Python 25.8% | Jupyter Notebook 74.2% | Python 25.8%
🌐
GitHub
github.com › majwilson › python-to-javascript
GitHub - majwilson/python-to-javascript: A tool that allows programmers to convert code written in Python into the equivalent code written in Javascript. · GitHub
A tool that allows programmers to convert code written in Python into the equivalent code written in Javascript. - majwilson/python-to-javascript
Starred by 27 users
Forked by 5 users
Languages   Python 94.3% | JavaScript 5.7%
🌐
GitHub
github.com › jiricekcz › javascript-to-python
GitHub - jiricekcz/javascript-to-python: My attempt to create a translator from simple Javascript to python
A javascript to python translator Currently supported JavaScript syntax features Currently translated native JavaScript functions and constants Currently translated JavaScript native classes and their methods and operators Currently translated Node.js modules with the functions supported Usage example
Author   jiricekcz
🌐
Gitloop
gitloop.com › tool › python-to-javascript
Python to JavaScript Code Converter
⬇️ Paste or enter your Python code and easily convert it to JavaScript with a single click.Try GitLoop — The AI That Knows Your Entire Codebase
Top answer
1 of 4
39

You can translate JavaScript to Python using Js2Py. It supports whole JavaScript and you can use it to translate large JavaScript modules like esprima.js (a JavaScript 6 parser).


Short demo:

>>> import js2py
>>> f = js2py.eval_js( "function $(a) {return a + arguments[1]}" )
>>> f
function $(a) { [python code] }
>>> f(1, 2, 3)
3

This is how the translated function looks like internally (it's rather ugly):

>>> print js2py.translate_js( "function $(a) {return a + arguments[1]}" )
from js2py.pyjs import *
var = Scope( JS_BUILTINS )
set_global_object(var)
# Code follows:
var.registers([u'$'])
@Js
def PyJsHoistedNonPyName(a, this, arguments, var=var):
    var = Scope({u'a':a, u'this':this, u'arguments':arguments}, var)
    var.registers([u'a'])
    return (var.get(u'a')+var.get(u'arguments').get(u'1'))
PyJsHoistedNonPyName.func_name = u'$'
var.put(u'$', PyJsHoistedNonPyName)
2 of 4
20

Updated

Now several (4) years later this (almost certainly) can be done; though certainly not with RegEx. I suggest future readers look to @Piotr Dabkowski's answer.. Or some of the other answers. (I don't know having not tried them)


Original Answer

Hm this is a hard one. The definition of a compiler is translates from a higher level language to a lower level language. eg python to machine-code. or java to javascript (google has a rather famous compiler for this somewhere - its' what makes google doc easier to make) Python to javascript compilers abound. technically javascript to python would be a decompiler. (afaik)

I found some speculation about a javascript-python converter here: follow the tread through. it mostly speaks of how it wouldn't be too hard to do. I can't find anything , but that doesn't mean it's no out there.

Regex is not suitable, regex is suitable only for regular languages. programming languages are not normally regular languages. see this

🌐
Hacker News
news.ycombinator.com › item
ASK HN: How to engineer a JavaScript to Python migration? | Hacker News
March 18, 2025 - There are some jobs that contain rather simple JavaScript snippets, and I was trying to design a first prototype that simply takes the JS parts and runs them in a transpiler · In this respect, I found a couple of packages that could be leveraged: - js2py: https://github.com/PiotrDabkowski/Js2Py ...
🌐
PyPI
pypi.org › project › Js2Py
Js2Py
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser