$npx skillfedfor your agent

htpy

htpy - HTML in Python

Worth itPyPI HTMLReleased May 2026207.0K downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — htpy-26.5.1-py3-none-any.whl
v26.5.1 · released 2026-05-22 · Python >=3.10 · 2 runtime deps: markupsafe, typing_extensions

Yes. htpy is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive MIT license. It is well-suited if you prefer writing HTML in Python over templates and want static typing and debugging support. Not necessary if you are already satisfied with your templating approach or need Python versions below 3.10.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.10 or later.
  • Low friction: pure Python wheel with only two lightweight runtime dependencies (markupsafe, typing_extensions).
  • Active maintenance with recent release 84 days ago and 477 repository stars.

License · maintenance · safety

MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open and closed projects with minimal restrictions.

last release 2026-05-22 (84 days) · last repo commit 2026-05-22 · 477 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 206,954 downloads/mo, #9,561 on PyPI

Verify before relying

pip install htpy

from htpy import html, head, body, title, h1, ul, li

result = html[
    head[title["Example"]],
    body[h1["Hello"], ul[(li[item] for item in ["one", "two"])]]
]
  • Whether the package's async support integrates seamlessly with specific ASGI frameworks beyond Starlette and FastAPI.
  • Performance characteristics when rendering large or deeply nested HTML structures.
  • Compatibility with type checkers other than mypy and pyright.
Same gist for agents: .md · .json

What it is and what it does

htpy is a Python library for generating HTML without templates. Instead of writing HTML strings or using a template language, you define HTML elements and structure using Python syntax—nesting child elements with brackets, passing attributes as function arguments, and composing components as regular Python functions or variables. It relies on markupsafe for safe HTML escaping and typing_extensions for type hints.

The library is designed to work with any Python web framework (Django, Flask, etc.) and supports async rendering for ASGI frameworks. Because HTML is just Python code, you can use static type checking with mypy or pyright, debug with standard Python debuggers, and leverage Python's full feature set—functions, classes, comprehensions, conditionals—to organize and reuse components. It was created to avoid the friction of template languages while maintaining the familiarity of Python development.

Use it for

  • Build server-rendered HTML components for htmx-driven interfaces without switching to a template language.
  • Generate complex, nested HTML structures in Flask or Django views using Python functions and comprehensions.
  • Type-check your HTML generation code with mypy or pyright to catch structural errors early.
  • Render HTML asynchronously in FastAPI or Starlette applications with full async/await support.
  • Create reusable HTML components as Python functions or classes that compose like regular code.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

htpy is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive MIT license. It is well-suited if you prefer writing HTML in Python over templates and want static typing and debugging support. Not necessary if you are already satisfied with your templating approach or need Python versions below 3.10.

Install

htpy on PyPI

Before you install

Low friction: pure Python wheel with only two lightweight runtime dependencies (markupsafe, typing_extensions). Active maintenance with recent release 84 days ago and 477 repository stars.

Requires Python 3.10 or later.

License in practice

MIT license permits unrestricted use, modification, and distribution in both open and closed projects with minimal restrictions.

Quickstart

pip install htpy

from htpy import html, head, body, title, h1, ul, li

result = html[
    head[title["Example"]],
    body[h1["Hello"], ul[(li[item] for item in ["one", "two"])]]
]

Verify before relying

  • Whether the package's async support integrates seamlessly with specific ASGI frameworks beyond Starlette and FastAPI.
  • Performance characteristics when rendering large or deeply nested HTML structures.
  • Compatibility with type checkers other than mypy and pyright.

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.10
Install frictionLow. Pure-Python wheel
Runtime dependencies
2 packages
markupsafetyping_extensions
MaintenanceActively maintained 84 days since the last release
Last repo commit
First released
Downloads206,954 / month, #9,561 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 4 - BetaIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3Topic :: Text Processing :: Markup :: HTMLTyping :: Typed

Evidence: htpy-26.5.1-py3-none-any.whl

Tags

Capabilities
HTML generation in Pythonwrite HTML with Python codetemplate-free HTML builderPython HTML DSLserver-side HTML renderinghtmx-friendly HTML generationasync HTML rendering
Topics
html-generationtype-safeasync-ready

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “write HTML with Python code”

  • htpyhtpy lets you write HTML directly in Python using bracket syntax and…
  • PlimPlim translates a concise Ruby-inspired template syntax into HTML and…
  • airiumAirium generates HTML from Python code using indentation and context…

Give your agent the search over MCP, or paste the wish link into any chat.

More HTML packages

MarkupSafe Worth it
PyPI · Dynamic Content · released Sep 2025

MarkupSafe provides a text object that escapes special characters so untrusted strings can be safely embedded in HTML and XML without injection attacks.

BSD-3-Clausecompiled wheel · 3.9+aging
797.1Mdownloads / mo
Jinja2 Worth it
PyPI · Dynamic Content · released Mar 2025

Jinja2 is a templating engine that renders dynamic content by combining templates with Python-like syntax and data, supporting template inheritance, macros, autoescaping, and sandboxed execution.

BSD-3-Clausepure Python · 3.7+aging
718.6Mdownloads / mo
beautifulsoup4 Worth it
PyPI · Python Modules · released Jun 2026

Beautiful Soup parses HTML and XML documents into a navigable tree, providing Pythonic methods to search, iterate, and modify the parsed content.

Install it if you need to parse or extract data from markup documents.

MITpure Python · 3.7.0+
432.1Mdownloads / mo
lxml Worth it
PyPI · Python Modules · released May 2026

lxml provides Python bindings to libxml2 and libxslt, enabling parsing, validation, and transformation of XML and HTML documents through an ElementTree-compatible API with support for XPath, XSLT, and schema validation.

Install it if you need robust XML/HTML parsing, validation, or transformation; avoid it only if you must stay pure-Python and can accept slower performance.

permissive licensecompiled wheel · 3.8+
416.8Mdownloads / mo
docutils With conditions
PyPI · Software Development · released May 2026

Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.

BSD-3-Clausepure Python · 3.9+
225.6Mdownloads / mo
Markdown Worth it
PyPI · Python Modules · released Jul 2026

Converts Markdown text to HTML using a Python implementation of John Gruber's Markdown specification, with support for extensions.

Install it if you need to parse Markdown in Python.

BSD-3-Clausepure Python · 3.10+
121.7Mdownloads / mo

See also htbuilder · tinyhtml · textile · html5tagger · dominate · python-fasthtml · htmlBuilder · html-text · tabulate · hyperscript