skillfed

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.

yattag v1.16.1 821.7K downloads/30d#4,973 on PyPI
Copyleft license DORMANT released

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 yattag

uv

uv add yattag

poetry

poetry add yattag

Installing 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

Environment :: Web EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)Operating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.2Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Topic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Software Development :: Libraries :: Python Modules

Tags

html generation pythonxml document builderpython template alternativeprogrammatic html markupform rendering with defaultshtml without templatesnested tag builder
html-generationmarkup-builderform-rendering

More Python Modules packages