hyperscript
HyperText with Python
What it is and what it does
Hyperscript is a lightweight Python library for building HTML markup using function calls rather than string concatenation or templates. You pass an element selector (tag name, optional class and id), attributes as a dictionary, and content as positional arguments, and it returns an HTML string. It supports nested elements, inline styles, boolean attributes, and class/id shorthand syntax similar to CSS selectors.
The library has no runtime dependencies and installs cleanly on Python 3.8+. It is dormant—the repository is not archived but has seen no commits since late 2024 and no releases in several months—so it is stable but not actively developed. It carries no known security vulnerabilities and is licensed under MIT, making it safe to use in most projects.
Use it for:
- Generate HTML snippets programmatically in web frameworks or static site generators without writing raw HTML strings.
- Build email templates or HTML reports dynamically from Python data structures.
- Create test fixtures or mock HTML for unit tests without external template files.
- Construct simple HTML documents or fragments in CLI tools or data processing scripts.
- Prototype web page layouts in Jupyter notebooks or interactive Python environments.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Hyperscript lets you generate HTML markup programmatically using Python function calls instead of writing HTML strings directly.
Yes, if you need lightweight programmatic HTML generation without template overhead. The package is stable, dependency-free, and permissively licensed. However, it is dormant—no active maintenance—so use it only for straightforward markup tasks where you do not expect ongoing support or feature additions. For complex templating or large-scale web applications, consider a maintained alternative.
Install
hyperscript on PyPI
pip
pip install hyperscriptuv
uv add hyperscriptpoetry
poetry add hyperscriptInstalling hyperscript
Before you install
Installation is straightforward with no runtime dependencies. The package is dormant—last commit was 2024-12-21 and no release since 2024-10-22—so expect no active maintenance or rapid bug fixes.
License in practice
MIT License is permissive, allowing commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely provided you retain the license notice.
Quickstart
pip install hyperscript
from hyperscript import h
print(h("p.greeting#msg", "Hello world!"))
Requires Python 3.8 or later.
Verify before relying
- Whether the package handles edge cases in attribute rendering (e.g., data attributes, custom namespaces) beyond the documented examples.
- Performance characteristics when generating large or deeply nested HTML structures.
- Whether there is a way to output formatted/pretty-printed HTML or only minified output.
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 661 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 511,792/month — #6,258 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: hyperscript-0.3.0-py3-none-any.whl
Tags
More HTML packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
airiumAirium generates HTML from Python code using…
permissive · top 15,000 on PyPI
htbuilderhtbuilder lets you construct HTML strings using…
permissive · top 15,000 on PyPI
python-fasthtmlFastHTML is a Python web framework that builds…
permissive · top 5,000 on PyPI
dominateDominate is a Python library for writing HTML…
copyleft · top 5,000 on PyPI
html5taggerGenerates HTML5 markup programmatically using…
permissive · top 5,000 on PyPI
empyEmPy is a templating system that embeds Python…
permissive · top 15,000 on PyPI
htmlBuilderRender HTML by writing Python code, using…
permissive · top 15,000 on PyPI
tinyhtmlRenders HTML5 safely from Python expressions…
permissive · top 15,000 on PyPI
htmltoolshtmltools provides Python functions to…
permissive · top 5,000 on PyPI
GenshiGenshi is a Python library for parsing,…
permissive · top 15,000 on PyPI