What is Transcrypt?

Definition

Transcrypt is a transpiler to compile a reasonably large Python code into compact, readable JavaScript. It takes the Python code that you write and converts it into a JavaScript file. That JS file can then be loaded into a web browser, and the code run.

Notably, no browser plug-in or large JavaScript runtime download is required to run the code. Also, the code is pre-compiled into JavaScript before it is downloaded to the browser, so application performance is not compromised.

Characteristics

It has the following characteristics:

  • It translates relatively large Python scripts into highly readable and easy to debug JavaScript code.

  • It is lightweight.

  • It offers the semantic essence of Python and the clean syntax that the language is famous for.

  • It works seamlessly with the JavaScript world of web-based libraries.

In two words: it’s lean and mean.

Installation required

Transcrypt has been tested under Windows, Linux, and OSX, with Chrome, Internet Explorer and Firefox. Follow the steps outlined below to get started:

  • Step 1: Go to Python official documentationhttps://www.python.org/ and download Python 3.9.

  • Step 2: Run the command python -m pip install transcrypt in the command prompt to install Transcrypt.

  • Step 3: Make a new folder called hello with the files hello.html and hello.py in it.

  • Step 4: Run the command python -m transcrypt -b -m -n hello.py from inside the new folder.

  • Step 5: Run the command python -m http.server from inside the new folder to start an HTTP server.

  • Step 6: Go to localhost:8000/hello.html in the browser to view the results.

The command would be python39 or python3 rather than python on Windows operating system. You may have to type python3.9 or python3 rather than python on Linux and macOS systems. To compile the test program on some systems, you can just type transcrypt -b -m -n hello.py.

Hello, solar system: A test application

We will test a hello, solar system application below. For the sake of simplicity, all the installations required are already performed. All you need to do is just click the “Run” button, and after that click the link given after “Your app can be found at”:

<script type="module">import * as hello from './__target__/hello.js'; window.hello = hello;</script>
<h2>Hello demo</h2>

<p>
<div id = "greet">...</div>
<button onclick="hello.solarSystem.greet ()">Click me repeatedly!</button>

<p>
<div id = "explain">...</div>
<button onclick="hello.solarSystem.explain ()">And click me repeatedly too!</button>

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved