Domonic: Generate HTML with Python 3

Domonic Not only a Python library for generating HTML

Domonic contains several main packages:

(but by no means are any of them complete)

  • html : Generate html with python 3 😎
  • dom : DOM API in python 3 😲
  • javascript : js API in python 3 😳
  • terminal || cmd : call terminal commands with python3 😱 (see at the end)
  • JSON : utils for loading / decorating / transformin
  • SVG : Generate svg using python (untested
  • aframe || x3d tags : auto generate 3d worlds with aframe. (see examples folder
  • dQuery - Utils for querying domonic. (alt + 0 for the º symbol)
  • geom - vec2, vec3 with _dunders_ as well as shape classes


from domonic.html import *

  output = render(
              div("hello world"),
              a("this is a link", _href="", _style="font-size:10px;"),
              ol(''.join([f'{li()}' for thing in range(5)])),
              h1("test", _class="test"),
<html><head><style></style><script></script></head><body><div>hello world</div><a href="" style="font-size:10px;">this is a link</a><ol><li></li><li></li><li></li><li></li><li></li></ol><h1 class="test">test</h1></body></html>


python3 -m pip install domonic

or if you had it before upgrade:

python3 -m pip install domonic --upgrade


print(html(body(h1('Hello, World!'))))

<html><body><h1>Hello, World!</h1></body></html>


There’s a few args you can pass to domonic on the command line to help you out.

To launch the docs for a quick reference to the APIs use:

python3 -m domonic -h

This command will attempt to generate a template from a webpage. (only simple pages for now)

python3 -m domonic -d

Then you can edit/tweak it to get what you need and build new components quicker.


Feel free to join in if you find it useful.

If there’s any methods you want that are missing or not complete yet. Just update the code and send a pull request.

I’ll merge and releaese asap.


A browser based file browser. Working example of how components can work:

A cron viewer:


There’s several more widely supported libraries doing HTML generation, DOM reading/manipulation, terminal wrappers etc. Maybe use one of those for production due to strictness and support.

This is becoming more of a fast prototyping library.