yattag
Generate HTML or XML in a pythonic way. Pure python alternative to web template engines.Can fill HTML forms with default values and error messages.
What it is and what it does
Yattag is a Python library for generating HTML and XML documents by writing code instead of using template engines. You build markup using context managers (with statements) that represent nested tags, making the document structure visually match the code indentation. The library also provides special methods for rendering HTML forms with default values and error messages pre-filled.
The package depends only on the standard library's typing module and is designed as a lightweight alternative to template engines. It trades template syntax for pure Python, which can be more readable for some use cases but requires more explicit code. The project is classified as dormant with no release in 650 days, and carries classifiers for Python 2 versions without a declared requires_python constraint, creating ambiguity about actual modern Python support.
Use it for:
- Generate HTML forms with pre-filled default values and error message display without a separate template file
- Build XML documents programmatically where the Python code structure mirrors the document hierarchy
- Create HTML snippets or full pages in web applications that prefer code-based markup over template syntax
- Render dynamic HTML in scripts or tools where a full template engine feels like overkill
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Yattag generates HTML or XML documents using Python code with context managers instead of template strings, letting you build nested markup programmatically with readable syntax.
Yes, if you prefer code-based HTML generation over templates and accept the maintenance risk. The package is stable with no known vulnerabilities, but dormant status and high install friction mean you should verify Python version compatibility for your target runtime before committing. Suitable for small projects or scripts where template overhead is unwelcome; risky for production systems requiring active maintenance.
Install
yattag on PyPI
pip
pip install yattaguv
uv add yattagpoetry
poetry add yattagInstalling yattag
Before you install
High install friction and dormant maintenance status (650 days since last release) suggest limited active support; the package carries Python 2 classifiers but no explicit requires_python constraint, creating uncertainty about actual compatibility with modern Python versions.
License in practice
Copyleft LGPL license means code using yattag must comply with LGPL terms; derivative works and modifications require source disclosure under the same license.
Quickstart
from yattag import Doc
doc, tag, text = Doc().tagtext()
with tag('html'):
with tag('body'):
with tag('h1'):
text('Hello world!')
print(doc.getvalue())
Verify before relying
- Whether the package actually supports modern Python versions despite listing Python 2.6 and 2.7 in classifiers with no explicit requires_python
- Current state of the GitHub repository and whether the project is actively maintained despite the dormant status signal
- Actual download volume and production usage patterns given the dormant maintenance status
Package facts
| License | not declared (copyleft) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | 1 — typing |
| Maintenance | dormant — 650 days since the last release |
| First released | |
| Downloads | 821,703/month — #4,973 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: yattag-1.16.1.tar.gz
Keywords: html, template, templating, xml, document, form, rendering
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
html5taggerGenerates HTML5 markup programmatically using…
permissive · top 5,000 on PyPI
htmltoolshtmltools provides Python functions to…
permissive · top 5,000 on PyPI
MarkupPyMarkupPy generates HTML and XML markup from…
permissive · top 5,000 on PyPI
GenshiGenshi is a Python library for parsing,…
permissive · top 15,000 on PyPI
hyperscriptHyperscript lets you generate HTML markup…
permissive · top 15,000 on PyPI
empyEmPy is a templating system that embeds Python…
permissive · top 15,000 on PyPI
htpyhtpy lets you write HTML directly in Python…
permissive · top 15,000 on PyPI
tinyhtmlRenders HTML5 safely from Python expressions…
permissive · top 15,000 on PyPI
brancaBranca generates HTML and JavaScript pages from…
permissive · top 5,000 on PyPI
ChameleonChameleon is an HTML/XML template engine that…
permissive · top 15,000 on PyPI