trafaret
Validation and parsing library
What it is and what it does
Trafaret is a validation and data transformation library that lets you define schemas to check and convert incoming data—configs, JSON, form submissions, or any structured input. You write a schema once (using a shorthand syntax or composable validator objects), then call it to validate and transform data; if the data doesn't match, you get detailed error messages showing exactly what failed and where.
The library supports custom error messages, context passing during validation, and async checking via async_check. It has no runtime dependencies, making it lightweight to add to a project. However, the package has been abandoned since April 2022 with no recent commits, so it receives no maintenance or security updates.
Use it for:
- Validate JSON payloads in web APIs before processing, catching malformed or missing fields early
- Check and transform configuration files (YAML, JSON, TOML) at startup to ensure required keys and correct types
- Validate and normalize form submissions in web applications, converting string inputs to the correct types
- Build data pipelines that require strict schema enforcement, transforming data as it flows through stages
- Parse and validate user input in CLI tools, ensuring arguments and options meet expected formats
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Trafaret validates and transforms foreign data (JSON, configs, user input) against schemas you define, with support for custom error messages and async checking.
Yes, if you need a lightweight, dependency-free validation library and can accept that the package is no longer maintained. The API is stable and works well for straightforward schema validation tasks. No, if you require active maintenance, security updates, or support for the latest Python versions—consider an actively maintained alternative like Pydantic or Marshmallow instead.
Install
trafaret on PyPI
pip
pip install trafaretuv
uv add trafaretpoetry
poetry add trafaretInstalling trafaret
Before you install
Low install friction with no runtime dependencies. However, the package is abandoned—last release was 2022-04-01 and no commits since then. Use only if you accept the risk of no future maintenance or security updates.
License in practice
BSD license is permissive; you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install trafaret
import trafaret as t
validator = t.Dict(a=t.Int, b=t.List(t.String))
result = validator.check({'a': 5, 'b': ['lorem', 'ipsum']})
Verify before relying
- Whether the package works reliably with modern Python versions (requires_python is unspecified in the fact sheet)
- Whether async_check and aiohttp support mentioned in the description are fully functional in version 2.1.1
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 1,596 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 964,396/month — #4,625 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: trafaret-2.1.1-py3-none-any.whl
Keywords: validation, form, forms, data, schema
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
schemaValidates Python data structures (dicts, lists,…
permissive · top 1,000 on PyPI
jsonschema-pydanticConverts JSON Schema definitions into Pydantic…
unclear · top 15,000 on PyPI
fastjsonschemaValidates JSON data against JSON Schema…
permissive · top 1,000 on PyPI
schematicsSchematics defines, validates, and transforms…
permissive · top 15,000 on PyPI
yamaleYamale validates YAML files against a schema…
permissive · top 5,000 on PyPI
jsoncompatChecks whether evolving JSON Schemas remain…
unclear · top 15,000 on PyPI
eidoValidates project metadata against PEP schemas…
permissive · top 15,000 on PyPI
snaptimeSnaptime transforms timestamps using a simple…
unclear · top 15,000 on PyPI
asdf-transform-schemasProvides ASDF schemas for validating transform…
unclear · top 15,000 on PyPI
transliterateConverts text between Latin and non-Latin…
copyleft · top 15,000 on PyPI