Skip to main content

Pydantic SchemaForms

Pydantic SchemaForms logo

PyPI version Downloads Downloads Downloads XERJ Corpus Hub contributor

Support Python Versions

Static Badge Ruff Coverage Status Tests Status Versioning: Year-Quarter-Build

CI/CD Pipeline: Testing - Main Testing - Dev

SonarCloud:

Coverage Maintainability Rating Quality Gate Status Reliability Rating Vulnerabilities


Requires Python 3.14+ — this library uses Python 3.14 language features and will not import on older versions.

Overview

pydantic-schemaforms turns a Pydantic model into a server-rendered HTML form, and validates what comes back with the same model.

from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse

from pydantic_schemaforms import Field, FormModel, html, render_form_html_async


class SignupForm(FormModel):
    name: str = Field(title='Full name', min_length=2)
    email: str = Field(title='Email', ui_element='email')


app = FastAPI()
RENDER_OPTIONS = {'include_framework_assets': True, 'asset_mode': 'cdn'}


@app.get('/signup', response_class=HTMLResponse)
async def show_signup():
    return await render_form_html_async(SignupForm, submit_url='/signup', **RENDER_OPTIONS)


@app.post('/signup', response_class=HTMLResponse)
async def submit_signup(request: Request):
    result = SignupForm.validate(await request.form(), submit_url='/signup', **RENDER_OPTIONS)
    if not result.is_valid:
        return await result.render_with_errors_async()

    name = result.data['name']
    return html(t'<p>Thanks for signing up, {name}!</p>')

That's a complete FastAPI app: a styled signup form, browser and server validation, errors shown next to each field with the user's input kept, and the validated data as a plain dictionary. A Flask version is the same model with render_form_html() and request.form.

Features

  • One model for everything. The form, its validation, the validated data and, with as_api_model(), a typed JSON API all come from one Pydantic class.
  • Inputs from types. str, int, date, bool, Enum, Literal, EmailStr and more pick their input; Field(ui_element=...) chooses any of 40+ others (currency, tags, rating, code editor, file upload, ...).
  • Complex forms by nesting. Sub-forms, optional sub-forms and repeating lists, shown as sections, tabs, columns, an accordion or a step wizard with one layout= argument. Data and errors come back nested like the model.
  • Fields that respond. Show a field only when it applies with ui_show_when, enforced on the server too. Group fields and share rows with ui_group and ui_cols, keeping the data flat.
  • Review pages for free. render_display() shows validated data read-only, with the form's labels and sections, for confirmation pages.
  • Bootstrap, Material Design 3 or plain HTML, with opt-in dark mode for Bootstrap and Material, and assets inlined, linked from a CDN or left to your page.
  • Escaped by construction. All HTML is built with Python 3.14 t-strings and an escaping processor.
  • Accessibility-tested. Every input, layout and error state is checked with axe-core against WCAG 2.0–2.2 A and AA rules on every pull request.
  • More when you need it: live validation over HTMX, CSV import into an editable table, CSRF protection, rule-based validators and plugin hooks for your own inputs.

Install

uv add "pydantic-schemaforms[fastapi]"     # or [flask]
pip install "pydantic-schemaforms[fastapi]"

Requires Python 3.14+ (the library uses t-strings) and Pydantic 2.13+; tested on 3.14 and 3.15. Add the email extra if your forms use EmailStr.

Documentation

The docs at https://devsetgo.github.io/pydantic-schemaforms/ have:

  • Tutorial: from a first form to nested forms, layouts, styling and CSRF protection, with FastAPI and Flask versions of every example.
  • Advanced User Guide: live validation, data tables, JSON APIs, forms built at runtime, assets and plugin hooks.
  • Recipes: complete apps for contact forms, login and registration, edit forms, line items, file uploads, wizards and more.
  • Reference: every input, layout, field option and function.

The live demo shows every input, layout and kind of validation.

Using an AI coding assistant?

The package ships Agent Skills that match the installed version, so assistants don't suggest removed APIs. Install them into your project with library-skills:

uvx library-skills --claude

You get pydantic-schemaforms (build and fix forms), schemaforms-create ("create a login form"), schemaforms-convert (from Pydantic, WTForms, Django or JSON Schema), schemaforms-upgrade (from removed APIs) and schemaforms-document (document your forms). For assistants without skills support, python -m pydantic_schemaforms.ai_instructions claude --write writes the same guidance to CLAUDE.md; see the AI Assistants and Agent Skills page.

Accessibility

axe-core 4.14 runs against every example page, under Bootstrap and Material, in light and dark, and in the error state after a failed submit, and any serious or critical violation fails CI. This is testing, not a compliance claim: conformance depends on your whole application. See the Accessibility reference.

Contributing

Contributions are welcome; see the Contributing Guide and the Roadmap.

git clone https://github.com/devsetgo/pydantic-schemaforms.git
cd pydantic-schemaforms
make install
make tests

License

This project is licensed under the MIT License - see the LICENSE file for details: https://github.com/devsetgo/pydantic-schemaforms/blob/main/LICENSE

Metadata

Release files for pydantic-schemaforms 26.4.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydantic-schemaforms 26.4.5
File Size Uploaded Provenance Actions
pydantic_schemaforms-26.4.5.tar.gz 689.0 kB With provenance Details for pydantic_schemaforms-26.4.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydantic-schemaforms 26.4.5
File Interpreter ABI Platform Actions
pydantic_schemaforms-26.4.5-py3-none-any.whl Python 3 none any Details for pydantic_schemaforms-26.4.5-py3-none-any.whl

Total release size: 1.4 MB

Release files / pydantic_schemaforms-26.4.5.tar.gz

Download URL pydantic_schemaforms-26.4.5.tar.gz
Size 689.0 kB
Tags Source
SHA-256 checksum
How to use checksums
24749d02ab1f8e85d4d549e0a84d81a2aa7dda119ec82913bf8f595778788ba8
BLAKE2b-256 checksum
How to use checksums
48602e7b358febd4c96f129793d225291fab00731ba44ce932983a07596b75c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / pydantic_schemaforms-26.4.5-py3-none-any.whl

Download URL pydantic_schemaforms-26.4.5-py3-none-any.whl
Size 731.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc6e00f653c4e19c0a81208a7a9d6672f3870e4439c48d5913133488b5bbba76
BLAKE2b-256 checksum
How to use checksums
9744a46df1b9bdb9a3711a79a6319c183ea2067e59e9c0cd4614d38c69c4a3c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for pydantic-schemaforms 26.4.5

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pydantic_schemaforms-26.4.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page