skillfed

tinyhtml

A tiny library to safely render compact HTML5 from Python expressions.

tinyhtml v1.3.0 104.3K downloads/30d#12,758 on PyPI20
Permissive license MIT/Apache-2.0 DORMANT released

What it is and what it does

tinyhtml is a minimal Python library for building and rendering HTML5 safely. It provides a functional API where you compose HTML elements using the `h()` function, nest them by calling the result with child content, and render to a string. All text content and attributes are automatically escaped to prevent injection, with a `raw()` escape hatch for intentional unescaped HTML. The library produces compact output with no superfluous whitespace.

It integrates with Jupyter notebooks via `_repr_html_()` and works with the `__html__` protocol used by MarkupSafe and other template systems. You can write reusable templates as Python functions returning fragments, pass iterables as child elements, and use boolean or dictionary-valued attributes. The library includes mypy typings and supports Python 3.8 through 3.13.

Use it for:

  • Generate HTML dynamically in web applications or scripts without string concatenation or template files.
  • Build Jupyter notebook outputs programmatically with safe escaping and clean composition.
  • Create email templates or HTML reports by composing fragments as Python functions.
  • Integrate with Jinja2 or other template systems that support the `__html__` protocol.
  • Render pandas DataFrames or other objects with `_repr_html_()` support alongside custom HTML.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Renders HTML5 safely from Python expressions using a functional API with automatic escaping and compact output.

Yes, if you need lightweight HTML generation with safety guarantees. Zero dependencies and low install friction make it easy to adopt. Dormant maintenance is acceptable for a stable, narrow-scope library—no active bugs or vulnerabilities are known. Best suited for projects that prefer functional composition over template strings and don't require advanced features like comments or inline SVG.

Install

tinyhtml on PyPI

pip

pip install tinyhtml

uv

uv add tinyhtml

poetry

poetry add tinyhtml

Installing tinyhtml

Before you install

Low friction: pure Python wheel with no runtime dependencies. Maintenance is dormant—last release was 580 days ago, but the repository remains active with a recent commit on 2025-01-11 and no archived status.

License in practice

Dual-licensed under MIT and Apache License 2.0, both permissive. You may choose either license, giving flexibility for most projects.

Quickstart

pip install tinyhtml

from tinyhtml import h, frag

result = h("div", klass="container")(
    h("h1")("Hello"),
    h("p")("World")
).render()
print(result)

Verify before relying

  • Whether dormant maintenance (580 days since release) affects long-term compatibility with future Python versions beyond 3.13.
  • Performance characteristics when rendering very large HTML structures or deeply nested fragments.

Package facts

License MIT/Apache-2.0 (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 580 days since the last release
Last repo commit
First released
Downloads 104,254/month — #12,758 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: tinyhtml-1.3.0-py3-none-any.whl

Keywords: html, html5, vdom, functional-programming

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTPTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: Markup :: HTMLTyping :: Typed

Tags

html generation pythonsafe html renderinghtml builder libraryfunctional html templateshtml5 from pythoncompact html outputhtml escaping
html-generationfunctional-apijupyter-compatible

More Python Modules packages