Flask-WTF

Simple integration of Flask and WTForms with CSRF, file uploads, and reCAPTCHA

Library
PyPI
v1.3.0
1,508stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
70/100Good
Development Activity60
Maintenance44
Community88
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture82
Code Quality85
Innovation66
Learning Curve84

Flask-WTF is a Flask extension that integrates the WTForms library into Flask applications, making it easy to define, render, and validate web forms. It wires WTForms into Flask’s request handling so form data is populated automatically and validation happens with a single call.

On top of core form handling, Flask-WTF adds the practical features real web forms need: global CSRF protection with per-form and per-request tokens, secure file-upload fields with validators, internationalized error messages, and optional reCAPTCHA integration to guard against spam and bots.

What You Get

  • A FlaskForm base class that auto-populates from the Flask request and validates in one call
  • Built-in CSRF protection with tokens for forms and AJAX requests
  • File-upload fields with FileRequired and FileAllowed validators
  • Optional reCAPTCHA field and internationalized validation messages

Common Use Cases

  • Building and validating HTML forms in a Flask web application
  • Protecting form submissions and AJAX endpoints against CSRF attacks
  • Handling secure file uploads with type and presence validation
  • Adding reCAPTCHA to registration or contact forms to block bots

Under The Hood

Architecture - The package under src/flask_wtf/ is compact and role-split: form.py defines FlaskForm (subclassing WTForms Form) which auto-binds to the Flask request and adds validate_on_submit(); csrf.py implements the CSRFProtect extension and token generation/validation; file.py adds file-upload fields and validators; recaptcha/ provides the reCAPTCHA field, widget, and validator; and i18n.py wires translated error messages. Tech Stack - Pure Python built directly on WTForms and Flask (Pallets ecosystem), packaged with modern pyproject tooling and distributed on PyPI; itsdangerous is used for signing CSRF tokens. Code Quality - A mature, actively maintained extension (1.5k+ stars) with a documented test suite, clear module boundaries, and a small, stable surface consistent with Pallets conventions. API Design - The API is intentionally minimal and idiomatic: subclass FlaskForm, call validate_on_submit() in views, render fields and form.csrf_token in Jinja, and enable app-wide protection with CSRFProtect(app), all backed by thorough ReadTheDocs documentation.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search