pydantic-to-html
A Python library that automatically converts Pydantic models into structured HTML using safe and semantic defaults.
Overview
pydantic-to-html infers an appropriate HTML structure based on the types of fields in a Pydantic model, including support for nested models, lists, and forms for user input.
Installation
pip install pydantic-to-html
Usage
from pydantic import BaseModel
from pydantic_to_html import render_html
class User(BaseModel):
name: str
email: str
age: int
user = User(name="John Doe", email="john@example.com", age=30)
html = render_html(user)
print(html)
Features
- ✅ Automatic HTML Conversion – Converts any Pydantic model into a structured HTML representation.
- ✅ Recursive Nesting – Handles nested models and lists of models gracefully.
- ✅ Table-Based Rendering – Uses elements for structured data representation.
- ✅ List Support – Renders lists as
- or
- ✅ Automatic Form Generation – Can generate editable forms with elements.
- ✅ Type-Safe Defaults – Uses appropriate form fields based on the Pydantic field type (
str, int, bool, datetime, etc.). - ✅ Customizable Themes – Allows passing custom CSS classes or styles.
- ✅ HTMX Support – Optionally integrates HTMX for live updates.
- ✅ Validation & Constraints – Uses Pydantic field constraints to enforce validation on form inputs.
- , depending on the data type.
API
def render_html( model: BaseModel, editable: bool = False, theme: str | None = None, htmx: bool = False, htmx_mode: str = "full", # "full" | "inline" | "none" max_depth: int | None = None, ) -> str: """Converts a Pydantic model into HTML (table or form)."""
Type Mapping
Metadata
Release files for pydantic-to-html 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydantic_to_html-0.2.0.tar.gz | 17.4 kB | Without provenance | Details for pydantic_to_html-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydantic_to_html-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for pydantic_to_html-0.2.0-py3-none-any.whl |
Total release size: 28.3 kB
Release files / pydantic_to_html-0.2.0.tar.gz
| Download URL | pydantic_to_html-0.2.0.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
40db64421ae81e86fdf7beed8b83abd3159ebd7c67c71699be0a945d4fe709e6
|
|
BLAKE2b-256 checksum How to use checksums |
d483f4e08a7833e76298a952ebe5c58b6470abbede86f11ea82d9fcd4b152646
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Release files / pydantic_to_html-0.2.0-py3-none-any.whl
| Download URL | pydantic_to_html-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7359b10c734bde9a4d56e633c9b4746e73957e8b39bf460b66f0520ede5b0b2
|
|
BLAKE2b-256 checksum How to use checksums |
ddd4cf3b5d16452f42892817b7d2f0c4ae935ed7c6982767f859f07dee9239a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Security for pydantic-to-html 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.