Run Python in your browser with zero configuration – no server, just a script tag.
Pytml is a lightweight (~15KB) JavaScript library that acts as a bridge between Python and HTML via WebAssembly. Drop a single script tag into any static page, write your logic inside <py> tags, and it runs natively in the browser.
Add one line to your HTML:
<script src="https://pytml.vercel.app/pytml.js"></script>Option 1: Inline Python (Recommended for mobile/local)
<!DOCTYPE html>
<html>
<head>
<script src="https://pytml.vercel.app/pytml.js"></script>
</head>
<body>
<py>
print("Hello, world!")
name = input("Your name? ")
print(f"Hi {name}!")
</py>
</body>
</html>Option 2: External Python File (HTTP/HTTPS only)
<!DOCTYPE html>
<html>
<head>
<script src="https://pytml.vercel.app/pytml.js"></script>
</head>
<body>
<script type="text/python" src="script.py"></script>
</body>
</html>
py
name = input("Enter your name: ")
age = input("Enter your age: ")
print(f"Hello {name}, you are {age} years old!")If you're running HTML locally from your device (mobile or desktop):
Use inline tags — This is the only method that works with file:// protocol
Zero config – just add one script tag
Real I/O – print() and input() work live in the browser
Full error tracebacks – debug like a local REPL
Package support – NumPy, Pandas, Matplotlib via micropip
Privacy-first – no code ever leaves your browser
15KB wrapper – Pyodide loads lazily, page isn't blocked
Pytml is open-source under the Apache 2.0 License.
If you find Pytml useful, consider giving it a star on GitHub!