JS2PY - JavaScript to Python Converter
GitHubGitHub DOWNLOADDownload Pre-Made

Welcome to JS2PY!

JS2PY is a free tool that allows you to easily convert JavaScript code into Python. Simply add it to your project, and you’ll be able to seamlessly convert JavaScript into Python code.

How to Integrate JS2PY into Your Project

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>

Adding the GUI

<textarea id="inputJs" placeholder="Enter your JavaScript code here..."></textarea>
<button onclick="convertToPython()">Convert to Python</button>
<pre id="output"></pre>

As well as adding the main gui components and adding links to the data.json where the main functions are you can add css code to improve its design.

What I use (CSS Example)


<style>
body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    padding: 20px;
}
h1 {
    text-align: center;
}
textarea {
    width: 100%;
    height: 200px;
    font-size: 14px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    margin-bottom: 10px;
}
button {
    display: block;
    width: 100%;
    padding: 10px;
    background-color: #4CAF50;
    color: white;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}
button:hover {
    background-color: #45a049;
}
#output {
    background-color: #fff;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-family: monospace;
    font-size: 14px;
    white-space: pre-wrap;
}
</style>

Example Conversion

Example JavaScript:

const name = prompt("What's your name?");
console.log(`Hello, ${name}!`);
            

Converted Python:

name = input("What's your name? ")
print(f"Hello, {name}!")
            

Currently, JS2PY Requires the GUI

At the moment, there is no way to use JS2PY without the GUI, as we do not have a server setup. However, I am actively working on a solution that will allow you to use the conversion functionality without the need for the GUI in the future.