Pytml 2.5 — powered by Pyodide

Run Python in HTML.

Zero config. Zero backend. Zero build step. Just <py> and go.

Autoplay ↓
The premise

Pytml is a minimal JavaScript library that lets you write Python directly inside your HTML. No server, no setup, no build step. It wraps Pyodide, connects print and input to the browser, and runs everything client-side in WebAssembly.

01 / LOAD

Pyodide from CDN

The full Python runtime loads lazily in the background, compiled to WebAssembly.

import pyodide
→ 0.314.0.7
→ ~6MB (cached)
02 / BRIDGE

print & input work

Python's built-in I/O is wired straight to the browser — no hacks, no shims.

>>> print("hello")
hello
>>> input("name? ")
03 / SCAN

Finds <py> tags

Every Python block is detected, extracted, and queued — even if injected by React or Vue later.

<py1> ... </py1>
<py2> ... </py2>
✓ found 2 blocks
04 / RUN

Executes Python

Code runs in a sandboxed interpreter. Output is captured cleanly as it streams.

def hello():
  print("hi")
✓ ran in 3.4ms
05 / RENDER

Outputs to terminal

stdout, stderr, and Python tracebacks all appear inline with real line numbers and stack traces.

Traceback (most recent call last):
File "<py1>", line 3
01 / LOAD

Pyodide loads
from CDN.

The full CPython runtime — compiled to WebAssembly — initialises in the background. It's cached after the first visit, so reloads are near-instant.

02 / BRIDGE

print() and input()
just work.

Python's built-in I/O is connected to the browser DOM. No polyfills, no shims, no surprises — output and input behave exactly like a local REPL.

03 / SCAN

Finds every
<py> block.

Pytml scans the DOM for Python blocks — even ones injected later by React, Vue, or vanilla JS. Each numbered block gets its own isolated execution context.

04 / RUN

Executes code in
a sandbox.

Code runs safely in the browser. Nothing ever leaves the tab — no network calls, no backend, no data leaks. Perfect for privacy-sensitive demos.

05 / RENDER

Output renders
inline.

stdout, stderr, and full Python tracebacks appear directly in a styled terminal. Errors are as readable as they are locally — line numbers included.

What it gives you

Four things no other Python-in-HTML tool gets right.

Scroll down. The panels move sideways automatically. No backend, no config file, no build step.

01 / 04

Zero config

Drop a single script tag in your HTML. That's the entire setup. No py-config, no bundler, no environment file.

Setup time: 1 minute
02 / 04

Real I/O

Python's print() and input() are wired directly to the browser. Output streams live; input reads from a native prompt.

No polyfills · no shims
03 / 04

100% client-side

No code, input, or output ever leaves the browser tab. Everything runs in WebAssembly. Perfect for privacy-sensitive demos.

Privacy by default
04 / 04

Framework-agnostic

Works inside React, Vue, Svelte, or plain HTML. Pytml scans the DOM after any framework renders — no integration needed.

Apache 2.0 · ~15KB
When it shines

Where Pytml actually belongs.

Be honest — Pytml is not for everything. Here's where it genuinely wins.

Education & Tutorials

Embed live Python in courseware. Students run code without installing anything — instant feedback, zero setup.

Technical Blogs

Interactive code snippets — readers tweak and run Python right in the article. No server costs.

Data Science Demos

Show visualisations or data processing with Python, all client-side. Perfect for portfolio projects.

Rapid Prototyping

Test Python logic in the browser without spinning up a Flask app. Great for hackathons and quick POCs.

Not for: heavy backend processing, database operations, or production APIs — use Flask for that. Pytml is client-side only.

Honest comparison

Pytml is not a Flask replacement.

It's not PyScript either. But for static pages, demos, and education, it wins on setup speed, bundle size, and simplicity.

Feature Pytml PyScript Flask
Setup time✔ 1 minute~ 5+ minutes~ 10+ minutes
Server required✔ No — static✔ No — static✘ Yes — backend
Bundle size✔ ~15 KB~ Larger— N/A
Pyodide load✔ Lazy✘ Eager— N/A
Configuration✔ Zero~ py-config file~ Full project
Best for✔ Demos · education~ Complex apps~ Full-stack
Built with

The stack that makes it run

Python JavaScript WebAssembly Pyodide ES6 HTML5 Bash GitHub Vercel Apache 2.0 Python JavaScript WebAssembly Pyodide ES6 HTML5 Bash GitHub Vercel Apache 2.0
0 KB
Bridge size
0
Servers needed
0%
Client-side
0 min
To first Python run
Questions

Frequently asked.

The Pytml wrapper is ~15KB minified. The Pyodide runtime (~6MB) is loaded lazily from CDN only when Python code actually runs, so the initial page load isn't blocked.
Yes. Pytml is framework-agnostic. Drop the script tag into any page — including ones generated by React or Vue. It scans the DOM for <py> tags after the framework renders.
Any package available in the Pyodide distribution — including NumPy, Pandas, Matplotlib, SciPy, and scikit-learn. C-extensions work only if they've been compiled to WebAssembly.
Python tracebacks render directly in the browser terminal — with line numbers and stack traces, just like a local REPL. Syntax errors, runtime exceptions, and import errors all surface normally.
No. Everything runs client-side in WebAssembly. No Python code, input, or output ever leaves your browser tab — which makes Pytml ideal for privacy-sensitive demos.
Python runs in a WebAssembly sandbox — roughly 2–5× slower than native CPython for CPU-bound work, with memory capped at the browser tab's allocation (usually 2–4GB). For demos, data viz, and scripting, it's more than enough.

Just <py>
and go.

See Python running live in your browser. No install. No server. No surprises.

Made from Laziness of Aswanth R (NodeX-AR)

Hello,
How can I help you?
💬 Ask about Pytml
💬