← Back to all products

Form Builder

$29

Build accessible HTML forms from Python templates with validation, zero dependencies.

📁 10 files
JSONMarkdownPython

📄 Product Preview

Try the interactive reader and demo tools below, or get the full product with all content unlocked.

📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample

📁 File Structure 10 files

form-builder/ ├── LICENSE ├── README.md ├── examples/ │ └── contact_form.json ├── free-sample.zip ├── guide/ │ ├── 01_features.md │ ├── 02_json-form-definition-schema.md │ ├── 03_configuration-reference.md │ └── 04_license.md ├── index.html └── src/ └── form_builder.py

📖 Documentation Preview README excerpt

Form Builder

Build accessible HTML forms from Python — no templates, no dependencies.

Part of the [Form Forge](https://form-forge.codevault.dev) toolkit by CodeVault.

Features

  • Programmatic HTML form generation from Python dataclasses or JSON
  • Built-in CSRF token generation (cryptographically secure)
  • Honeypot anti-spam field out of the box
  • Full ARIA accessibility: labels, describedby, required markers
  • Client-side HTML5 validation attributes (required, minlength, pattern, etc.)
  • All standard input types: text, email, select, radio, checkbox, textarea, file, date, etc.
  • JSON-driven form definitions — load forms from config files
  • Zero dependencies — Python 3.10+ stdlib only

Quick Start


# Render the built-in demo contact form
python src/form_builder.py --demo

# Render from a JSON definition
python src/form_builder.py --input examples/contact_form.json

# Write output to a file
python src/form_builder.py --input examples/contact_form.json --output form.html

JSON Form Definition Schema


{
  "action": "/api/contact",
  "method": "POST",
  "id": "contact-form",
  "class": "form",
  "csrf": true,
  "honeypot": true,
  "submitLabel": "Send Message",
  "fields": [
    {
      "name": "email",
      "type": "email",
      "label": "Email Address",
      "placeholder": "you@example.com",
      "required": true,
      "autocomplete": "email"
    }
  ]
}

Field Properties

PropertyTypeDescription
namestringField name attribute (required)
typestringInput type: text, email, select, textarea, etc.

... continues with setup instructions, usage examples, and more.

📄 Code Sample .py preview

src/form_builder.py #!/usr/bin/env python3 """ Form Builder — Programmatic HTML Form Generation ================================================= Build accessible, validated HTML forms from Python dictionaries. Includes CSRF protection, client-side validation attributes, ARIA labels, and customizable rendering. Part of the Form Forge toolkit by DataNest. License: MIT """ from __future__ import annotations import argparse import hashlib import html import json import logging import os import secrets import sys import time from dataclasses import dataclass, field from enum import Enum from typing import Any logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s") logger = logging.getLogger(__name__) # --------------------------------------------------------------------------- # Constants # --------------------------------------------------------------------------- CSRF_TOKEN_LENGTH = 32 # bytes → 64 hex chars DEFAULT_METHOD = "POST" DEFAULT_ENCTYPE = "application/x-www-form-urlencoded" MULTIPART_ENCTYPE = "multipart/form-data" class FieldType(Enum): """Supported HTML input types.""" TEXT = "text" EMAIL = "email" PASSWORD = "password" NUMBER = "number" TEL = "tel" URL = "url" DATE = "date" DATETIME_LOCAL = "datetime-local" TIME = "time" # ... 419 more lines ...
Buy Now — $29 Back to Products