skillfed

htmltools

Tools for HTML generation and output.

htmltools v0.7.0 917.1K downloads/30d#4,726 on PyPI24
Permissive license MIT License Copyright (c) 2023 Posit Software, PBC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),… (full text in the JSON record) Active released

What it is and what it does

htmltools is a Python library for building HTML documents and fragments programmatically. It provides a set of functions and classes to construct HTML elements, nest them, set attributes, and render them to strings. The library is designed for developers who need to generate HTML dynamically from Python code—whether for web applications, templating systems, or documentation generation.

The package depends only on typing-extensions and packaging, keeping its footprint minimal. It supports modern Python versions from 3.10 onward and is actively maintained. The library fits into workflows where HTML generation is a core task but a full templating engine may be overkill, making it suitable for programmatic HTML construction in frameworks, data reporting tools, or custom HTML builders.

Use it for:

  • Generate HTML reports or dashboards programmatically from Python data structures.
  • Build HTML fragments dynamically in web frameworks or template systems.
  • Construct email bodies or HTML documents for automated document generation.
  • Create interactive HTML output for Jupyter notebooks or data analysis tools.
  • Serialize Python objects to structured HTML for web display or export.

Worth the install?

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

htmltools provides Python functions to programmatically create, manipulate, and serialize HTML documents and fragments.

Yes. htmltools is a lightweight, actively maintained library with no known vulnerabilities, permissive licensing, and minimal dependencies. It fills a clear niche for programmatic HTML generation in Python. Install it if you need to build HTML dynamically from code rather than using string templates or a heavier templating framework.

Install

htmltools on PyPI

pip

pip install htmltools

uv

uv add htmltools

poetry

poetry add htmltools

Installing htmltools

Before you install

Low install friction with only two lightweight runtime dependencies (typing-extensions and packaging). Active maintenance with a recent release 85 days ago and ongoing repository activity.

License in practice

MIT License permits unrestricted use, modification, and distribution in both open-source and commercial projects, with only the requirement to include the license notice.

Quickstart

pip install htmltools

from htmltools import HTML, div, p

html_content = div(
    p("Hello, World!"),
    id="container"
)
print(html_content.render())

Requires Python 3.10 or later.

Verify before relying

  • Whether the package supports streaming or incremental HTML rendering for large documents.
  • Performance characteristics when generating very large HTML structures.
  • Availability and completeness of API documentation beyond the repository README.

Package facts

License MIT License Copyright (c) 2023 Posit Software, PBC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 2 — typing-extensions, packaging
Maintenance actively maintained — 85 days since the last release
Last repo commit
First released
Downloads 917,074/month — #4,726 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: htmltools-0.7.0-py3-none-any.whl

Keywords: html

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: PyPyTopic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: Markup :: HTML

Tags

html generation pythoncreate html programmaticallyhtml manipulation librarypython html builderhtml serializationdynamic html outputhtml templating
html-generationmarkup-builder

More Python Modules packages