--- id: dominate version: "2.9.1" license: LGPL-3.0-or-newer license_treatment: copyleft maintenance: active --- # dominate — Dominate is a Python library for creating and manipulating HTML documents using an elegant DOM API. License: copyleft · Maintenance: active · Downloads: 2.1M/mo ## What it is and what it does Dominate provides a Pythonic way to construct HTML by treating each HTML element as a Python class. You instantiate tags, nest them using context managers or method chaining, set attributes via keyword arguments or dictionary-like access, and render the result to a string. The library eliminates the need to write raw HTML or learn a separate templating syntax—instead, you write pure Python code that reads naturally and lets you use Python's full feature set (loops, conditionals, functions) to generate markup. The package is lightweight with zero runtime dependencies and works across Python 3.7 through 3.12 as well as PyPy. It supports both human-readable pretty-printing and compact rendering, handles HTML5 data attributes, provides shortcuts for reserved keywords like `class` and `for`, and allows you to build reusable widget functions using decorators. It's commonly used for server-side HTML generation, dynamic page building, and creating HTML-based reports or documentation. Use it for: - Generate HTML pages dynamically in web frameworks without a separate template engine. - Build reusable HTML components as decorated Python functions for modular page construction. - Create HTML reports or documentation programmatically from Python data structures. - Generate email templates or HTML content in backend services without string concatenation. - Prototype or test HTML structures in Python without writing raw markup strings. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Dominate is a Python library for writing HTML documents programmatically using a DOM API, letting you generate HTML pages in pure Python without learning a template language. Yes. Dominate is a mature, actively maintained library with no dependencies, broad Python version support, and no known vulnerabilities. The copyleft license (LGPL-3.0) requires source disclosure if you distribute the library itself, but poses no barrier for internal or open-source use. Install it if you prefer writing HTML in Python over templates or string manipulation. ## Install pip install dominate uv add dominate poetry add dominate ## Installing dominate Before you install: Installation is straightforward with no runtime dependencies. The package is actively maintained with recent commits and a stable release history since 2013, supporting current Python versions (3.7–3.12 and PyPy). License in practice: Dominate is licensed under LGPL-3.0-or-newer (copyleft). If you distribute software that links or bundles this library, you must make your source code available under compatible terms. Quickstart: pip install dominate import dominate from dominate.tags import div, p, html, body doc = dominate.document(title='Example') with doc: with div(id='content'): p('Hello, World!') print(doc) Verify before relying: - Performance characteristics when generating very large HTML documents or deeply nested structures. - Whether the library supports HTML5 semantic elements beyond standard tag coverage. ## Package facts - License: LGPL-3.0-or-newer (copyleft) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 2.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags python html generation, html dom api, generate html in python, html templating without templates, python html builder, programmatic html creation, html document generation, html-generation, templating-alternative [View on SkillFed](https://skillfed.io/packages/dominate) · [View on PyPI](https://pypi.org/project/dominate/)