--- id: htbuilder version: "0.9.0" license: Apache 2 license_treatment: permissive maintenance: dormant --- # htbuilder — A purely-functional HTML builder for Python. Think JSX rather than templates. License: permissive · Maintenance: dormant · Downloads: 251.1K/mo ## What it is and what it does htbuilder is a lightweight HTML string generator that replaces template languages with pure Python function calls. Instead of writing HTML templates or concatenating strings, you import tag names (div, span, ul, etc.) as functions and call them with content and attributes as arguments. The package supports multiple syntaxes—positional arguments, keyword arguments, chained calls with parentheses, or bracket notation—so you can choose the style that reads most naturally to you. The core value is that HTML generation becomes just Python: you can use loops, conditionals, and variables directly in your markup without template syntax. It also provides helper functions for common patterns like building style strings, class lists, and CSS units. With no runtime dependencies and a permissive license, it's a minimal, self-contained tool for scenarios where you need to generate HTML programmatically rather than render from a template. Use it for: - Generate HTML email bodies or reports dynamically in Python without learning a template language. - Build web scraper output or data-driven HTML documents where structure depends on runtime conditions. - Construct HTML fragments in web frameworks (e.g., Streamlit, FastAPI) where inline Python markup is clearer than templates. - Programmatically create test fixtures or mock HTML responses in unit tests. - Generate static site content or documentation where HTML structure is computed from data structures. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. htbuilder lets you construct HTML strings using Python function calls and operators instead of template syntax, supporting attributes, nested elements, and conditional rendering through pure Python code. Yes, if you prefer writing HTML in Python and don't need frequent updates. The package is stable, has no security vulnerabilities, and solves a real problem for developers who dislike template syntax. The dormant maintenance and source-only distribution are minor friction, but the zero runtime dependencies and permissive license make it low-risk for projects that can tolerate infrequent upstream changes. ## Install pip install htbuilder uv add htbuilder poetry add htbuilder ## Installing htbuilder Before you install: Installation friction is high—the package ships as a source distribution only. Maintenance is dormant: the last commit was 2025-01-09, but the prior release cycle was 582 days earlier, suggesting infrequent updates. The repository remains active (not archived) with 104 stars. License in practice: Licensed under Apache 2 (permissive), which allows commercial and private use with minimal restrictions. No notable licensing constraints for most use cases. Quickstart: pip install htbuilder from htbuilder import div, ul, li dom = div(id='container')[ ul(_class='items')[ li('item 1'), li('item 2'), ] ] print(dom) Requires Python 3.7 or later. Verify before relying: - Whether high install friction (source-only distribution) impacts real-world adoption or if wheels are available through alternative channels. - Performance characteristics when building large or deeply nested HTML structures. - Whether dormant maintenance status affects compatibility with newer Python versions beyond 3.7. ## Package facts - License: Apache 2 (permissive) - Python support: supports_current - Install friction: high - Maintenance: dormant - Downloads: 251.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags html string builder python, functional html generation, python html templating alternative, programmatic html construction, html dom builder, jsx-like python html, html-generation, functional-programming [View on SkillFed](https://skillfed.io/packages/htbuilder) · [View on PyPI](https://pypi.org/project/htbuilder/)