pscript
Python to JavaScript compiler.
What it is and what it does
PScript is a Python-to-JavaScript compiler that translates a carefully defined subset of Python into executable JavaScript. It was originally built as part of the Flexx framework and now stands as a standalone tool. The compiler takes Python functions and classes and outputs equivalent JavaScript code, allowing developers to write browser-facing code using Python syntax and semantics.
The package is pure Python with no external dependencies, making installation trivial. It targets modern browsers (Firefox, Chrome, Edge) and Internet Explorer 9 and above, though some newer Python constructs like async/await do not work in older browsers. The generated JavaScript handles Python-specific features like default arguments and prints to the browser console. It is actively maintained and used in production projects like TimeTagger.app.
Use it for:
- Build interactive web frontends where you want to write client-side logic in Python rather than JavaScript.
- Compile Python functions to JavaScript for use in web applications or browser-based tools.
- Develop Flexx-based applications that automatically transpile Python UI code to run in the browser.
- Create hybrid Python/JavaScript projects where business logic can be shared or ported between server and client.
- Prototype browser interactions and DOM manipulation using Python syntax before or instead of learning JavaScript.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PScript compiles a Python subset to JavaScript, enabling you to write browser-facing code in Python syntax instead of JavaScript.
Yes, if you need to write browser code in Python. The package has no dependencies, installs cleanly, is actively maintained, and solves a real problem for teams that prefer Python syntax. The main gotcha is that only a Python subset compiles—you need to verify your code will translate before committing to this approach.
Install
pscript on PyPI
pip
pip install pscriptuv
uv add pscriptpoetry
poetry add pscriptInstalling pscript
Before you install
Installation is straightforward: the package is pure Python with no runtime dependencies, distributed as a wheel, and requires Python 3.8 or later. The project is actively maintained with a recent release.
Quickstart
from pscript import py2js
def foo(a, b=2):
print(a - b)
print(py2js(foo))
Requires Python 3.8 or later; only a subset of Python syntax is supported (not all Python features compile to JavaScript).
Verify before relying
- Exact scope of Python subset supported (which language features compile and which do not)
- Performance characteristics of generated JavaScript compared to hand-written code
- Browser compatibility details beyond the stated modern-browser and IE9+ support
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 136 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 284,719/month — #8,061 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pscript-0.8.1-py3-none-any.whl
Keywords: Python, JavaScript, compiler, transpiler, parser
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
CoffeeScriptCompiles CoffeeScript code to JavaScript from…
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
telepathtelepath serializes Python objects to…
permissive · top 5,000 on PyPI
Js2PyJs2Py translates and executes JavaScript code…
permissive · top 5,000 on PyPI
lesscpyCompiles LESS stylesheets to CSS using Python,…
permissive · top 15,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
quickjs-rsExecutes JavaScript code inside a WebAssembly…
permissive · top 15,000 on PyPI
quickjsWraps the QuickJS C library to execute…
unclear · top 5,000 on PyPI