๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ schema
schema ยท PyPI
schema is a library for validating Python data structures, such as those obtained from config-files, forms, external services or command-line parsing, converted from JSON/YAML (or something else) to Python data-types.
      ยป pip install schema
    
Published ย  Oct 11, 2025
Version ย  0.7.8
๐ŸŒ
Pydantic
docs.pydantic.dev โ€บ 1.10 โ€บ usage โ€บ schema
Schema - Pydantic
All sub-models' (and their sub-models') schemas are put directly in a top-level definitions JSON key for easy re-use and reference. "Sub-models" with modifications (via the Field class) like a custom title, description or default value, are recursively included instead of referenced. The description for models is taken from either the docstring of the class or the argument description to the Field class.
๐ŸŒ
jsonschema
python-jsonschema.readthedocs.io
jsonschema 4.26.0 documentation
PyPI version Supported Python versions Build status ReadTheDocs status pre-commit.ci status Zenodo DOI jsonschema is an implementation of the JSON Schema specification for Python. It can also be us...
๐ŸŒ
Python-cerberus
docs.python-cerberus.org
Cerberus โ€” Data validation for Python
>>> schema = {'name': {'type': 'string'}} >>> v = Validator(schema)
๐ŸŒ
Python-cerberus
docs.python-cerberus.org โ€บ schemas.html
Validation Schemas - Cerberus โ€” Data validation for Python
Cerberus schemas are built with vanilla Python types: dict, list, string, etc. Even user-defined validation rules are invoked in the schema by name as a string. A useful side effect of this design is that schemas can be defined in a number of ways, for example with PyYAML. >>> import yaml >>> schema_text = ''' ... name: ... type: string ... age: ... type: integer ... min: 10 ... ''' >>> schema = yaml.safe_load(schema_text) >>> document = {'name': 'Little Joe', 'age': 5} >>> v.validate(document, schema) False >>> v.errors {'age': ['min value is 10']}
๐ŸŒ
GitHub
github.com โ€บ keleshev โ€บ schema
GitHub - keleshev/schema: Schema validation just got Pythonic ยท GitHub
This can be used to add word completion, validation, and documentation directly in code editors. The output schema can also be used with JSON schema compatible libraries. Just define your schema normally and call .json_schema() on it. The output is a Python dict, you need to dump it to JSON.
Starred by 2.9K users
Forked by 217 users
Languages ย  Python
๐ŸŒ
Polars
docs.pola.rs โ€บ api โ€บ python โ€บ dev โ€บ reference โ€บ schema โ€บ index.html
Schema โ€” Polars documentation
Ordered mapping of column names to their data type ยท The schema definition given by column names and their associated Polars data type. Accepts a mapping, or an iterable of tuples, or any object implementing the __arrow_c_schema__ PyCapsule interface (e.g. pyarrow schemas)
๐ŸŒ
Horejsek
horejsek.github.io โ€บ python-fastjsonschema
Fast JSON schema for Python โ€” fastjsonschema documentation
Support only for Python 3.3 and higher. fastjsonschema implements validation of JSON documents by JSON schema. The library implements JSON schema drafts 04, 06, and 07. The main purpose is to have a really fast implementation.
๐ŸŒ
Google Cloud
cloud.google.com โ€บ python โ€บ documentation โ€บ reference โ€บ class schema (0.13.12)
Class Schema (0.13.12) | Python client library | Google Cloud
Defines the structure and layout of a type of document data. This message has oneof_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time.
Find elsewhere
๐ŸŒ
Pylonsproject
docs.pylonsproject.org โ€บ projects โ€บ colander โ€บ en โ€บ latest
colander 2.0 documentation - The Pylons Project
colander 2.0 documentation ยป ยท Colander ยท Colander is useful as a system for validating and deserializing data obtained via XML, JSON, an HTML form post or any other equally simple data serialization. It is tested on Python 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, and 3.10, and PyPy 2.7 and PyPy 3.8. Colander can be used to: Define a data schema.
๐ŸŒ
Python-arango
docs.python-arango.com โ€บ en โ€บ main โ€บ schema.html
Schema Validation โ€” python-arango documentation
my_schema = { 'rule': { 'type': 'object', 'properties': { 'name': {'type': 'string'}, 'email': {'type': 'string'} }, 'required': ['name', 'email'] }, 'level': 'moderate', 'message': 'Schema Validation Failed.' } employees = db.create_collection(name='employees', schema=my_schema) # Modify the schema.
๐ŸŒ
Apache Arrow
arrow.apache.org โ€บ cookbook โ€บ py โ€บ schema.html
Working with Schema โ€” Apache Arrow Python Cookbook documentation
Arrow automatically infers the ... Python objects to Arrow objects. However, you might want to manually tell Arrow which data types to use, for example, to ensure interoperability with databases and data warehouse systems. This chapter includes recipes for dealing with schemas...
Top answer
1 of 10
76

You may use schema (PyPi Link)

schema is a library for validating Python data structures, such as those obtained from config-files, forms, external services or command-line parsing, converted from JSON/YAML (or something else) to Python data-types.

from schema import Schema, And, Use, Optional, SchemaError

def check(conf_schema, conf):
    try:
        conf_schema.validate(conf)
        return True
    except SchemaError:
        return False

conf_schema = Schema({
    'version': And(Use(int)),
    'info': {
        'conf_one': And(Use(float)),
        'conf_two': And(Use(str)),
        'conf_three': And(Use(bool)),
        Optional('optional_conf'): And(Use(str))
    }
})

conf = {
    'version': 1,
    'info': {
        'conf_one': 2.5,
        'conf_two': 'foo',
        'conf_three': False,
        'optional_conf': 'bar'
    }
}

print(check(conf_schema, conf))
2 of 10
36

Use Pydantic!

Pydantic enforces type hints at runtime, and provides user friendly errors when data is invalid. Define how data should be in pure, canonical python; validate it with pydantic, as simple as that:

from pydantic import BaseModel


class Info(BaseModel):
    conf_one: float
    conf_two: str
    conf_three: bool

    class Config:
        extra = 'forbid'


class ConfStructure(BaseModel):
    version: int
    info: Info

If validation fails pydantic will raise an error with a breakdown of what was wrong:

my_conf_wrong = {
    'version': 1,

    'info': {
        'conf_one': 2.5,
        'conf_two': 'foo',
        'conf_three': False,
        'optional_conf': 'bar'
    }
}

my_conf_right = {
    'version': 10,

    'info': {
        'conf_one': 14.5,
        'conf_two': 'something',
        'conf_three': False
    }
}

model = ConfStructure(**my_conf_right)
print(model.dict())
# {'version': 10, 'info': {'conf_one': 14.5, 'conf_two': 'something', 'conf_three': False}}

res = ConfStructure(**my_conf_wrong)
# pydantic.error_wrappers.ValidationError: 1 validation error for ConfStructure
#     info -> optional_conf
# extra fields not permitted (type=value_error.extra)
๐ŸŒ
Readthedocs
python-jsonschema-objects.readthedocs.io โ€บ en โ€บ latest โ€บ Introduction.html
What โ€” Python JSONSchema Objects 0.0.18 documentation
Literal values are wrapped when constructed to support validation and other schema-related operations. However, you can still use them just as you would other literals. >>> import python_jsonschema_objects as pjs >>> builder = pjs.ObjectBuilder(examples['Example Schema']) >>> ns = builder.build_classes() >>> Person = ns.ExampleSchema >>> james = Person(firstName="James", lastName="Bond") >>> str(james.lastName) 'Bond' >>> james.lastName += "ing" >>> str(james.lastName) 'Bonding' >>> james.age = 4 >>> james.age - 1 3 >>> 3 + james.age 7 >>> james.lastName / 4 Traceback (most recent call last): ...
๐ŸŒ
jsonschema
python-jsonschema.readthedocs.io โ€บ en โ€บ stable โ€บ validate
Schema Validation - jsonschema 4.26.0 documentation
The Basics: The simplest way to validate an instance under a given schema is to use the validate function. The Validator Protocol: jsonschema defines a protocol that all validator classes adhere to...
๐ŸŒ
jsonschema
python-jsonschema.readthedocs.io โ€บ en โ€บ latest โ€บ validate
Schema Validation - jsonschema - Read the Docs
The Basics: The simplest way to validate an instance under a given schema is to use the validate function. The Validator Protocol: jsonschema defines a protocol that all validator classes adhere to...
๐ŸŒ
GitHub
github.com โ€บ frictionlessdata โ€บ tableschema-py
GitHub - frictionlessdata/tableschema-py: A Python library for working with Table Schema. ยท GitHub
A Python implementation of the Table Schema standard.
Starred by 266 users
Forked by 39 users
Languages ย  Python 99.4% | Makefile 0.6%
๐ŸŒ
Synapse
python-docs.synapse.org โ€บ en โ€บ stable โ€บ tutorials โ€บ python โ€บ json_schema
Working with JSON Schema - Synapse Python/Command Line Client Documentation
June 17, 2025 - JSON Schema is a tool used to validate data. In Synapse, JSON Schemas can be used to validate the metadata applied to an entity such as project, file, folder, table, or view, including the annotations applied to it. To learn more about JSON Schemas, check out JSON-Schema.org.