MarkupPy: An HTML/XML Generator

1.18 · active · verified Mon Apr 13

MarkupPy is a Python module designed to simplify the generation of HTML/XML from Python code in an intuitive, lightweight, and Pythonic manner. It supports both Python 2 and 3 environments, offering a straightforward approach to creating markup. The library maintains an active status with intermittent releases, with version 1.18 being published in March 2025.

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize an HTML page, add a title, paragraphs, and a link. Elements are added as method calls on the page object. Closing tags are explicitly called for block elements like 'p'.

from MarkupPy import markup

# Create an HTML page
page = markup.page()
page.init(title="My Title", lang="en")
page.h1("Welcome!")
page.p("Hello, World!")
page.p.close()
page.a("Visit GitHub", href="https://github.com/tylerbakke/MarkupPy")
print(page)

view raw JSON →