Flask-Pydantic
Flask extension that integrates Pydantic for typed request and response validation.
Repository Health
Technical Analysis
Flask-Pydantic is a Flask extension that brings Pydantic’s typed data validation to Flask request handling. With a single validate decorator, it parses and validates query strings, JSON bodies, and form data against Pydantic models, then exposes the validated objects to your view function with proper type hints.
Part of the Pallets Community Ecosystem, the extension removes the boilerplate of manually reading and checking request parameters. Invalid input is rejected with structured error responses automatically, and response models can be serialized on the way out, giving Flask APIs the same ergonomic, model-driven validation popularized by modern typed frameworks.
What You Get
- A validate decorator that parses query, body, and form parameters into Pydantic models
- Typed access to validated data as function arguments or request attributes
- Automatic 400 responses with structured validation error details
- Optional response model serialization for consistent output
- Compatibility with both Pydantic v1 and v2 style models
Common Use Cases
- Validating JSON request bodies for Flask REST endpoints
- Parsing and type-checking URL query parameters
- Enforcing form-data schemas on submission handlers
- Serializing responses through Pydantic models for consistent APIs
Under The Hood
Architecture - The extension is compact: flask_pydantic/core.py implements the validate decorator that inspects the request, builds the declared Pydantic models from query, body, and form data, and attaches results to Flask’s request proxy or passes them as arguments. flask_pydantic/converters.py adapts query-string parsing, and flask_pydantic/exceptions.py defines the validation error responses returned to clients.
Tech Stack - Pure Python built on Flask and Pydantic, with support for both Pydantic v1 and v2 models. It has no other runtime dependencies and installs as a standard Flask extension.
Code Quality - The tests directory includes functional tests (func), unit tests, a dedicated pydantic_v1 suite, and shared fixtures via conftest, exercising both validation success and error paths across Pydantic versions. Maintained under Pallets-Eco, the small codebase is easy to audit.
API Design - The API is intentionally minimal: import validate, annotate a view with query/body/form Pydantic models, and read typed data directly. It mirrors patterns developers know from FastAPI while staying idiomatic to Flask, keeping the learning curve short.
Used by 2 apps in this directory
QRev
CRM · AI Agents
Open source AI-first sales platform that replaces Salesforce with autonomous agents handling prospecting, outreach, and lead management at scale.
Second Me
Productivity · AI Assistants
Train a locally hosted AI twin on your own memories—then connect it to the world through a decentralized identity network.