ztml
A Rust-backed framework for building websites in pure Python. Define HTML, CSS, and JS using Python expressions with full autocompletion. Inspired by FastHTML.
Read my documentation
Install
pip install ztml
Quick example
from ztml import *
page = render(
Html(
Head(Meta().charset("utf-8"), Title("My App")),
Body(
H1("Hello, ztml!"),
P("Build websites with Python.").cls("intro"),
A("GitHub").href("https://github.com").target("_blank"),
),
)
)
Every HTML element has a constructor. Attributes are set via chained builder methods. CSS is built with Rule, Media, and Keyframes, with 400+ typed property methods generated from W3C specs:
Style(
Rule("body").margin("0").font_family("system-ui, sans-serif"),
Rule(".container").display("flex").gap("1rem").padding("2rem"),
Media("max-width: 768px",
Rule(".container").flex_direction("column"),
),
)
The built-in server handles routing, sessions, SSE, and WebSockets:
from ztml import *
from ztml.scripts import HTMX
from ztml.server import rt, serve
@rt('/')
def get():
return Html(
Head(Title("Counter"), HTMX),
Body(
H1("Counter"),
P("0").id("count"),
Button("Increment").hx_post("/increment").hx_target("#count"),
),
)
count = 0
@rt('/increment')
def post():
global count
count += 1
return P(str(count)).id("count")
serve() # localhost:5001
See the docs for the full guide on HTML elements, CSS styling, JavaScript helpers, custom components, and the server layer.
Examples
uv run examples/static_page.py > page.html
uv run examples/counter_server.py
uv run examples/todo_server.py
uv run examples/auth_app.py
uv run examples/ws_chat.py
uv run examples/sse_clock.py
Benchmarks
Compared against FastHTML building and rendering nested HTML element trees:
Scenario Library Elements Build (ms) Render (ms) Total (ms)
---------------------------------------------------------------------------
10x50 ztml 1040 1.44 0.09 1.54
10x50 fasthtml 1040 14.72 2.62 17.35
speedup: build 10.2x, render 28.5x, total 11.3x
50x100 ztml 10200 14.65 0.90 15.55
50x100 fasthtml 10200 151.36 26.12 177.61
speedup: build 10.3x, render 28.9x, total 11.4x
100x200 ztml 40400 58.04 3.63 61.69
100x200 fasthtml 40400 710.79 106.00 816.57
speedup: build 12.2x, render 29.2x, total 13.2x
^ benchmarks/bench.py (M3 Pro MacBook Pro)
Building from source
Prerequisites: Rust toolchain, Python 3.12+, uv.
uv sync
uv run maturin develop
cargo run --bin gen_stubs --no-default-features # regenerate .pyi stubs
Running tests
uv run python -m pytest
cargo test -p ztml-core
Releasing
Bump the version in crates/ztml-core/Cargo.toml and crates/ztml-python/Cargo.toml, make sure stubs are up to date, then:
git add -A && git commit -m "bump version to 0.x.y"
git tag v0.x.y
git push && git push origin v0.x.y
The v* tag triggers the full build matrix (Linux, macOS, Windows) and publishes to PyPI.
License
Metadata
Release files for ztml 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ztml-0.2.5.tar.gz | 56.7 kB | With provenance | Details for ztml-0.2.5.tar.gz |
Built distributions (wheels)
Total release size: 21.6 MB
Release files / ztml-0.2.5.tar.gz
| Download URL | ztml-0.2.5.tar.gz |
|---|---|
| Size | 56.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20493914492310eda6787431a7eb16ca2c4a6b0da2ffee2c4afa84ef89c1f5cf
|
|
BLAKE2b-256 checksum How to use checksums |
490a510cee1aa8c814be338a57e37055200d863e7e36baf82374729a9694b811
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp314-cp314-win_amd64.whl
| Download URL | ztml-0.2.5-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
74241c009391e831654f458e1ef9d2258852cad51cf95f4f424b5ec9f0490f77
|
|
BLAKE2b-256 checksum How to use checksums |
87ce6e22480145a5b2411bfd0a2d093ab5a91458b097fd760466fa00ff586b22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ztml-0.2.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
4cf60f9c996f2b63f72de688c1908101b0af7070ee87a3f98b30844819848fb3
|
|
BLAKE2b-256 checksum How to use checksums |
477f79698485031d4ea9827c5de045436e03084c181e29c5a9949002c9a50178
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ztml-0.2.5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
2622dea8e38e719698ddd4a66324339aeba2244fdb2f1e58f3e9edc3009fda97
|
|
BLAKE2b-256 checksum How to use checksums |
e9b936b19fb66b7b26f2b025fc9378db4d19caf664f2f89ec73e4c67b044d051
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | ztml-0.2.5-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4a6543aff4e9ea7b19ea2864e7e5ef888fbb50e5a6cc9b615912d51178d6dd60
|
|
BLAKE2b-256 checksum How to use checksums |
fe4d92743ed793420291333cbce157e9f3e4d2571a4fe67f0da9dfa72db645f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp314-cp314-macosx_10_12_x86_64.whl
| Download URL | ztml-0.2.5-cp314-cp314-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.14 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
e1d6593e8db036d9a23c20eb98c40fd08204305c0773e15f2e71b71579f68f63
|
|
BLAKE2b-256 checksum How to use checksums |
fd6bc88749df17b7e61b9bfed402801ed4403a83da36ee000d22cef878d2b304
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp313-cp313-win_amd64.whl
| Download URL | ztml-0.2.5-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e14d00da4f85c499e6be0c2d1ddc618b42bdea370079debae36718c834349320
|
|
BLAKE2b-256 checksum How to use checksums |
c44330d16a208998c997d772191972f95d094c3fd37c10271b215ba0d554369b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ztml-0.2.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
2428661464a178bbf1bd33c951a20b5b4f3551d3433887c2444681fe0f1d183f
|
|
BLAKE2b-256 checksum How to use checksums |
09557d532a21b23a802614c80fa85614e34c258274bee9dc5c299584b560f7e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ztml-0.2.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
029fa81b3089ccf6e6e5779dff53000c53095d02e459cfd8460f2a8e17449017
|
|
BLAKE2b-256 checksum How to use checksums |
a7debc30d665af6bbefaec1cbd01a3ff9a8a207ab76e7df1927c1df785bcc0c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | ztml-0.2.5-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
451a299cdaab8d9a2121fc6361231db317de35893a8dc184065d8fc23d69532a
|
|
BLAKE2b-256 checksum How to use checksums |
095ada46d4f1fbecd568e427af51647eb81ccfb8a22b18f0cbc4b1a257f58ca8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp313-cp313-macosx_10_12_x86_64.whl
| Download URL | ztml-0.2.5-cp313-cp313-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.13 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
e37e98d8bb77016b9e7b9dd0d1c194d25f899a9dd3e556ce9cff08e423608b18
|
|
BLAKE2b-256 checksum How to use checksums |
498c8e56c807be66c6be5df2ce189ebb9073c5ff9fe2320d69dabbe83495b3ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp312-cp312-win_amd64.whl
| Download URL | ztml-0.2.5-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9e7f54d7cbff5c64c2f8352fa723e79a7a9d566f3e8eaee4b75f04a97c8cd12f
|
|
BLAKE2b-256 checksum How to use checksums |
0afdd010787328c1772ffd6ee722a5a0f79105cf53195507fd38c90fe205d888
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ztml-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
bd181cceacadc2d1bda403613389bf426e79e4bb31b893c950587e0bb1cd4140
|
|
BLAKE2b-256 checksum How to use checksums |
f910d26c6bd6d9d32d9f30f2fb08adc8c4aabccb335a8f47575179bf36a5f4f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ztml-0.2.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
a551523f31219aa3f0ed75329fbb28413db90cef1a0b467dc008c60a908b1608
|
|
BLAKE2b-256 checksum How to use checksums |
97ab02946ef452ca136d239bcf22c252835315182d6250e5ae67cf9d6fc3fd33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | ztml-0.2.5-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4404952a8e0f8fdeecf3de86063852945767144954c08294c8fcb346b57f0e4f
|
|
BLAKE2b-256 checksum How to use checksums |
7133208020de46fba3d51b5c17d7312f24381af983facdd9bb497e9e9912b92c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logRelease files / ztml-0.2.5-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | ztml-0.2.5-cp312-cp312-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.12 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b1a0eb7dab36ec161277a52da851ddc87c673792dcf0c19cd19fea70002d04fb
|
|
BLAKE2b-256 checksum How to use checksums |
414a0076716d080902c1c73a0de3b9464b578a096c8737fb1d45cb57652c52be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logSecurity for ztml 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 16 files in this release have been uploaded with provenance metadata.
Attestation for ztml-0.2.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.