Stage 02 · Test · Researched comparison
Best Python Validation Libraries in 2026
Pydantic is the first pick for most teams. It validates data through Python type hints, runs on Python 3.9 and later, and suits API request models and settings. Marshmallow is a strong alternative when you need separate load and dump schemas for serialization. Cerberus fits teams that want schema dictionaries without type annotations. All three are open source and free.
By Shihab Mia
Published 27 Nov 2026 · 7 tools compared
We run no ads and no affiliate links at launch. The order of a list follows our published method. See how we score.
Prices are the starting prices vendors list publicly. Plans change, so confirm the current price on the vendor page before you buy.
Key takeaways
- Pydantic, Marshmallow, Cerberus, voluptuous, jsonschema and attrs are all free and open source.
- Pydantic relies on type hints; Marshmallow and Cerberus use explicit schema definitions.
- jsonschema validates against JSON Schema drafts, which helps when schemas are shared across languages.
- None of these libraries send your data to a third party; validation runs in your own Python process.
Who each pick is for
- Type-hint validation for APIs and settingsPydantic
- Schema-based validation with serializationMarshmallow
- Dictionary schema validation without annotationsCerberus
- Compact schema validation in small scriptsvoluptuous
- Validating data against JSON Schema documentsjsonschema
- Class definition with optional validatorsattrs
- Validating HTML form input in DjangoDjango Forms
Comparison
| Tool | Best for | Standout feature | Listed starting price | Free plan or trial |
|---|---|---|---|---|
| 1Pydantic | Type-hint validation for APIs and settings | Rules come from standard type hints | Free (open source) | Free plan |
| 2Marshmallow | Schema-based validation with serialization | Clear separation of load and dump | Free (open source) | Free plan |
| 3Cerberus | Dictionary schema validation without annotations | Plain dict schemas are easy to store or load from config | Free (open source) | Free plan |
| 4voluptuous | Compact schema validation in small scripts | Small API with readable schema literals | Free (open source) | Free plan |
| 5jsonschema | Validating data against JSON Schema documents | Implements JSON Schema drafts | Free (open source) | Free plan |
| 6attrs | Class definition with optional validators | Validators attach to typed attributes | Free (open source) | Free plan |
| 7Django Forms | Validating HTML form input in Django | Built into Django | Free (open source) | Free plan |
How we picked
We picked libraries that are maintained, documented and licensed clearly, and that genuinely validate data rather than only serialize it. Criteria were fit for common Python validation jobs, supported Python versions, licence and price, whether data stays local, and main limits. Sources are vendor documentation, project repositories and public pricing pages. All listed tools are free and open source. Prices and terms change, so confirm details on the vendor site.
The tools, one by one
Pydantic
Best for type-hint validation for APIs and settings

What it is and where it fits
Pydantic builds validators from Python type annotations. You declare a model class with typed fields, and Pydantic checks incoming data, coerces types where allowed, and raises structured errors. It runs on Python 3.9 and later and is distributed under the MIT licence. The v2 line uses a Rust core for speed.
It is the default choice for request and response models in FastAPI and works well for environment settings through pydantic-settings. It also handles nested models, custom validators and JSON Schema export. The main cost is learning its coercion and strict-mode behavior, since defaults can accept values you did not expect. Teams on v1 should plan the v2 migration. Skip it if you prefer schema dictionaries over annotated classes.
Standout: Rules come from standard type hints
Free (open source), as listed by the vendor (Pydantic website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Rules come from standard type hints
- fast core written in Rust
- strong FastAPI integration
Drawbacks
- Strict mode and coercion rules take time to learn
- v1 to v2 migration needs code changes
Skip it if this limit matters to you: strict mode and coercion rules take time to learn.
Verdict. A sensible pick for type-hint validation for APIs and settings.
Alternatives in this guide: Marshmallow, Cerberus, voluptuous
Marshmallow
Best for schema-based validation with serialization

What it is and where it fits
Marshmallow defines schemas as classes with explicit fields. Each field declares its type and options, and the schema validates input on load and formats output on dump. It runs on modern Python 3 versions and is released under the MIT licence. The project is maintained and has a long history in the Flask and Django ecosystems.
Its strength is deserialization and serialization in one place, which suits APIs that need to shape output as well as check input. You can nest schemas, add pre and post processing hooks, and reuse fields. The tradeoff is verbosity: a schema for a large model takes more lines than an equivalent Pydantic model. It also lacks Pydantic's compiled core, so very high-throughput paths may be slower. Skip it if you want validation driven purely by type hints.
Standout: Clear separation of load and dump
Free (open source), as listed by the vendor (Marshmallow website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Clear separation of load and dump
- mature ecosystem and framework integrations
- good error messages
Drawbacks
- Schemas are verbose compared with type hints
- no built-in Rust-speed core
Skip it if this limit matters to you: schemas are verbose compared with type hints.
Verdict. A sensible pick for schema-based validation with serialization.
Alternatives in this guide: Pydantic, Cerberus, voluptuous
Cerberus
Best for dictionary schema validation without annotations

What it is and where it fits
Cerberus validates Python dictionaries against schema dictionaries. A schema lists allowed keys, types, required flags and rules, and you can extend it with custom validators. It runs on Python 3 and is distributed under the ISC licence. Because schemas are plain data, you can keep them in YAML or JSON files and load them at runtime.
That makes Cerberus a good fit for config validation and for teams that want rules separated from code. It also supports normalization, so it can coerce or rename values before checking. The limits are real: it does not read type hints, so it does not integrate with typed codebases the way Pydantic does, and its community is smaller. Skip it if you need deep framework integration or JSON Schema output.
Standout: Plain dict schemas are easy to store or load from config
Free (open source), as listed by the vendor (Cerberus website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Plain dict schemas are easy to store or load from config
- supports custom rules and normalization
Drawbacks
- No type-hint integration
- smaller ecosystem than Pydantic or Marshmallow
Skip it if this limit matters to you: no type-hint integration.
Verdict. A sensible pick for dictionary schema validation without annotations.
Alternatives in this guide: Pydantic, Marshmallow, voluptuous
voluptuous
Best for compact schema validation in small scripts

What it is and where it fits
voluptuous validates data against schemas written as Python expressions. A schema can be as short as a dict mapping keys to types, and you can add validators, defaults and coercion. It runs on Python 3 and is released under the BSD licence. The codebase is small and the API is easy to read in place.
It suits scripts, config files and small services where a full framework is overkill. It handles nested structures and required keys, and error messages point at the failing path. The main drawback is project activity: development is slower than Pydantic or Marshmallow, and documentation is thinner. Check the repository before adopting it for a long-lived project. Skip it if you need active feature work or a large community.
Standout: Small API with readable schema literals
Free (open source), as listed by the vendor (voluptuous website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Small API with readable schema literals
- supports defaults and coercion
Drawbacks
- Less active development
- limited documentation compared with larger projects
Skip it if this limit matters to you: less active development.
Verdict. A sensible pick for compact schema validation in small scripts.
Alternatives in this guide: Pydantic, Marshmallow, Cerberus
jsonschema
Best for validating data against JSON Schema documents

What it is and where it fits
jsonschema validates Python data against JSON Schema documents. It supports multiple drafts and is released under the MIT licence. Because JSON Schema is a language-neutral standard, the same schema can validate data in other services and languages, which helps when contracts are shared across teams.
Use it when the schema already exists as JSON, when you validate API payloads against a published contract, or when you need format checks. It is not a serialization or object-mapping library, so it does not replace Pydantic or Marshmallow for model building. Error output can be verbose, and complex schemas take time to write. It runs on Python 3 and is maintained by the Python JSonSchema organization.
Standout: Implements JSON Schema drafts
Free (open source), as listed by the vendor (jsonschema website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Implements JSON Schema drafts
- schemas are portable across languages
- good for API contracts
Drawbacks
- JSON Schema has a learning curve
- not a general object-mapping tool
Skip it if this limit matters to you: JSON Schema has a learning curve.
Verdict. A sensible pick for validating data against JSON Schema documents.
Alternatives in this guide: Pydantic, Marshmallow, Cerberus
attrs
Best for class definition with optional validators

What it is and where it fits
attrs generates class boilerplate and lets you attach validators to attributes. You declare fields and add validators such as instance_of or custom callables, and attrs runs them when an object is created. It runs on Python 3 and is released under the MIT licence. The project is actively maintained.
It fits codebases that already use attrs for data classes and want light validation at construction time. It also works with cattrs for structured conversion. The limits are scope: attrs does not parse JSON, does not produce JSON Schema, and does not replace a request-validation layer. Skip it if you need schema documents or framework-level request checking. Use it when validation is a small part of a class definition.
Standout: Validators attach to typed attributes
Free (open source), as listed by the vendor (attrs website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Validators attach to typed attributes
- less boilerplate than plain classes
- widely used
Drawbacks
- Validation is secondary to class generation
- not a schema or serialization framework
Skip it if this limit matters to you: validation is secondary to class generation.
Verdict. A sensible pick for class definition with optional validators.
Alternatives in this guide: Pydantic, Marshmallow, Cerberus
Django Forms
Best for validating HTML form input in Django

What it is and where it fits
Django Forms validate and clean HTML form input inside a Django project. A form class declares fields, and Django runs field-level and form-level cleaning, collects errors and can render the form. It ships with Django under the BSD licence and runs wherever Django runs.
It is the right tool when the input comes from an HTML form in a Django app. ModelForm extends it to model-backed forms. Outside Django it is not usable, so it is not a general-purpose validator. For JSON APIs in Django, teams often pair Django REST Framework serializers with the framework. Skip it if you are not on Django or if the input is JSON rather than form data.
Standout: Built into Django
Free (open source), as listed by the vendor (Django Forms website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Built into Django
- handles cleaning, errors and rendering
- well documented
Drawbacks
- Tied to Django
- not usable as a standalone library
Skip it if this limit matters to you: tied to Django.
Verdict. A sensible pick for validating HTML form input in Django.
Alternatives in this guide: Pydantic, Marshmallow, Cerberus
Who should use what
If you build FastAPI or typed services, start with Pydantic. If you need load and dump schemas for a Flask or Django API, use Marshmallow. If you want schemas stored as config dictionaries, pick Cerberus. If you validate against a shared JSON Schema contract, use jsonschema. For small scripts, voluptuous is enough. If you already use attrs, add its validators. Django form input belongs in Django Forms.
Questions to settle before you buy
What to check before you buy
- Confirm the library supports your Python version and is actively maintained.
- Check the licence fits your project, since all listed tools are open source but terms differ.
- Decide whether you want type-hint models or explicit schema definitions.
- Test error output, because message quality affects debugging and API responses.
- Verify behavior on nested data, coercion and strict mode before relying on defaults.
FAQ
Is Pydantic free to use?
Yes. Pydantic is open source under the MIT licence. There is no paid tier required for the core library. Optional hosted services exist separately, but the validation library itself is free.
Can I use these libraries without sending data to a server?
Yes. All the libraries listed run inside your own Python process, so data is not sent to a third party. This differs from online validator web pages, where you should not paste secrets, tokens or production data.
What is the difference between Pydantic and Marshmallow?
Pydantic builds validation from type hints and is common in FastAPI. Marshmallow uses explicit schema classes and handles both loading and dumping. Pydantic is more concise for typed code; Marshmallow gives clearer control over serialization.
Does jsonschema replace Pydantic?
No. jsonschema checks data against JSON Schema documents and is language-neutral. Pydantic builds Python models and handles coercion and serialization. Some teams use both: Pydantic for models and jsonschema for shared contracts.
Which library should I use for Django forms?
Use Django Forms, which ships with Django. It handles field cleaning, error collection and rendering for HTML forms. For JSON APIs in Django, look at Django REST Framework serializers instead.
Sources we checked
Method: how we score · editorial policy.
Change log. First published 27 Nov 2026.