--- id: tinyhtml version: "1.3.0" license: MIT/Apache-2.0 license_treatment: permissive maintenance: dormant --- # tinyhtml — A tiny library to safely render compact HTML5 from Python expressions. License: permissive · Maintenance: dormant · Downloads: 104.3K/mo ## 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 above — 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 pip install tinyhtml uv add tinyhtml 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_current - Install friction: low - Maintenance: dormant - Downloads: 104.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags html generation python, safe html rendering, html builder library, functional html templates, html5 from python, compact html output, html escaping, html-generation, functional-api, jupyter-compatible [View on SkillFed](https://skillfed.io/packages/tinyhtml) · [View on PyPI](https://pypi.org/project/tinyhtml/)