PyFrontKit is a Python library that lets you build web views using pure Python, producing clean, professional HTML and CSS without replacing or hiding web standards.
It is not a framework — it’s a backend-friendly engine for structure, control, and clarity.
Developers often spend hours writing repetitive HTML and CSS. PyFrontKit allows you to:
- Reduce boilerplate while keeping full control
- Generate real, editable HTML and CSS
- Use Python logic (
if/else,for) to shape your page dynamically - Build production-ready pages to disk or directly in memory, with optional inline CSS
Structure first. Automation second. Control always.
- A Pythonic DSL for HTML and CSS
- A productivity tool that simplifies repetitive tasks
- A system that produces professional, editable code
- Suitable for static sites, landing pages, and Python-driven frontends
- A visual builder
- A framework that hides HTML/CSS
- A layout generator
- A runtime-dependent system
PyFrontKit helps you write less without thinking less.
- Blocks = HTML elements (
div,section,header, etc.) ctn_parameters = textual content inside a block- IDs are optional; required only for blocks receiving children later
Footer(ctn_p="© 2025 PyFrontKit") # simple block
Footer(id="page_footer") # can receive children later- Automatically converts line breaks (
\n) into<br /> - Supports multiple tags (
p,span,h1–h6,strong,em,code,mark) - Full triple-quoted strings supported
Div(ctn_p="Hello", style="color:red; padding:10px;")PyFrontKit generates selectors in style.css that are editable:
#page_footer {}
section {}
div {}CreateColor→ predefined palettes and templatesCreateWithColor→ define custom colors while using templates
Available templates:
simple, classic, soft, darkness, mono, mono_accent, total, total_v2, classic_reverse, dark_reverse, asimetric, enfasis_main
- Load custom or Google fonts
- Separate body, header, and footer typography
- Apply styles via CSS, never hardcoded
Generates files:
index.html
style.css
Returns a fully-rendered string, ready for frameworks like FastAPI or Flask, optionally with inline CSS for single-response delivery.
doc.create_template() # returns HTML+CSS stringfrom pyfrontkit import HtmlDoc, Header, Section, Div, Footer
doc = HtmlDoc(title="PyFrontKit Example")
Header(ctn_h1="Welcome to PyFrontKit")
Section(id="content")
content(
Div(ctn_p="This page was generated entirely with Python.")
)
Footer(ctn_p="© 2025 PyFrontKit")
doc.create_document() # writes index.html + style.cssPyFrontKit ships with two professional examples:
| File | Description |
|---|---|
example_1.py |
Landing page with hero sections and grids |
example_2.py |
Multi-section page demonstrating color & typography systems |
Check the
examples/folder to see PyFrontKit in action.
- Static websites
- Documentation generators
- Landing pages
- UI prototyping
- Teaching HTML & CSS structure
- Python-driven frontend workflows
pip install pyfrontkitor
pip install git+https://github.com/Edybrown/pyfrontkit.git- Deterministic output
- Tested with
pytest - No runtime dependencies
- Ideal for automation & CI pipelines
Eduardo Antonio Ferrera Rodríguez Focus: Python DSL, frontend structure, automation without abstraction loss, professional output
Licensed under MIT License