Pytml logo
PYTML python → html

$> Run Python in your browser – no backend, no bullshit

Lightweight alternative to PyScript & Flask

A zero‑config 15KB JavaScript library that lets you embed Python code directly in your HTML. Handles print(), input(), and errors – live, in the browser. No server. No heavy frameworks. Just <py> and go.

NITI Frontier Tech 15KB wrapper
Pytml

// The Lazy Bridge

Pytml is a minimal JavaScript library that lets you write Python inside your HTML – no server, no setup.

It wraps Pyodide (Python compiled to WebAssembly) and automatically redirects print() to a nice terminal box, and turns input() into a live form.

Built by Aswanth R (NodeX‑AR) – a Class 12 student who wanted a lazy way to show Python projects live on the web.

Why it exists

  • No Flask, no Django, no server
  • Just <py>code</py>
  • Works offline after first load
  • Less than 15KB of JS

Comparison

Just real trade‑offs. Pytml is not a Flask replacement for backends, and it's not as feature‑heavy as PyScript. But for static pages, demos, and education, it wins on speed, size, and simplicity.

Feature Pytml PyScript Flask
Setup time 1 min (1 tag) ~ 5 min (config) ~ 10+ min (env)
Server required No (static) No (static) Yes (backend)
Wrapper size ~15 KB ~ Larger bundle N/A
Pyodide load Lazy Eager N/A
Configuration Zero (<py>) ~ <py-config> ~ Full structure
Best for Demos, education Complex browser apps Full‑stack apps

* Pyodide (~6MB) loaded from CDN – same for both. Pytml adds a ~15KB wrapper + lazy loading.

# How It Works

1. Loads Pyodide (WebAssembly) from CDN
2. Overrides print() and input()
3. Finds all py script or <script type="text/python"> tags
4. Runs Python, catches output and errors
5. Displays everything in a styled terminal
<!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>

Features

Zero config

Just a script tag

Real I/O

print() and input() work

Any device

Works on phones too

Open source

Apache 2.0

When to Use Pytml

Be honest – Pytml shines here, not everywhere.

Education & Tutorials

Embed live Python in courseware. Students run code without installing anything – instant feedback.

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.

Not for: Heavy backend processing, database operations, or production APIs – use Flask for that. Pytml is client‑side only.

🧩 Built With

Python JavaScript WebAssembly Pyodide ES6 HTML5 Bash GitHub Vercel Apache 2.0 Python JavaScript WebAssembly Pyodide ES6 HTML5 Bash GitHub Vercel Apache 2.0

Frequently Asked Questions

What is the actual bundle size of Pytml?

The Pytml wrapper itself is ~15KB minified. The Pyodide runtime (~6MB) is loaded lazily from CDN only when you actually run Python code, so initial page load isn't blocked.

Can I use Pytml with React, Vue, or other JS frameworks?

Yes. Pytml is framework-agnostic. You can drop the script tag in any HTML page, including those generated by React or Vue. It scans the DOM for <py> tags after the framework renders.

What Python packages are supported?

Any pure-Python package available on Pyodide's repository – including NumPy, Pandas, Matplotlib, SciPy, and scikit-learn. C-extensions are not supported unless compiled to WebAssembly.

How does Pytml handle errors and debugging?

Python tracebacks are captured and rendered directly in the browser terminal box. Syntax errors, runtime exceptions, and import errors all appear with line numbers and stack traces, just like a local Python REPL.

Is there any server-side component or data sent to a backend?

No. Everything runs client-side in WebAssembly. No Python code, input, or output ever leaves your browser. This makes Pytml ideal for privacy-sensitive demos and educational tools.

What are the performance limitations?

Pytml runs Python in a WebAssembly sandbox. It's roughly 2-5x slower than native CPython for CPU-bound tasks, and memory is limited to the browser's tab allocation (usually 2-4GB). Heavy number crunching may be slower than server-side Python, but for demos, data viz, and scripting, it's perfectly fine.

[ Try It ]

See Pytml in action – run Python code live in your browser.

Made from Laziness of Aswanth R (NodeX-AR)