So far the closest thing I've been able to find is warlock, which advertises this workflow:

Build your schema

>>> schema = {
    'name': 'Country',
    'properties': {
        'name': {'type': 'string'},
        'abbreviation': {'type': 'string'},
    },
    'additionalProperties': False,
}

Create a model

>>> import warlock
>>> Country = warlock.model_factory(schema)

Create an object using your model

>>> sweden = Country(name='Sweden', abbreviation='SE')

However, it's not quite that easy. The objects that Warlock produces lack much in the way of introspectible goodies. And if it supports nested dicts at initialization, I was unable to figure out how to make them work.

To give a little background, the problem that I was working on was how to take Chrome's JSONSchema API and produce a tree of request generators and response handlers. Warlock doesn't seem too far off the mark, the only downside is that meta-classes in Python can't really be turned into 'code'.

Other useful modules to look for:

  • jsonschema - (which Warlock is built on top of)
  • valideer - similar to jsonschema but with a worse name.
  • bunch - An interesting structure builder thats half-way between a dotdict and construct

If you end up finding a good one-stop solution for this please follow up your question - I'd love to find one. I poured through github, pypi, googlecode, sourceforge, etc.. And just couldn't find anything really sexy.

For lack of any pre-made solutions, I'll probably cobble together something with Warlock myself. So if I beat you to it, I'll update my answer. :p

Answer from synthesizerpatel on Stack Overflow
🌐
PyPI
pypi.org › project › jsonschema
jsonschema · PyPI
>>> validate(instance={"name" : "Eggs", "price" : 34.99}, schema=schema) >>> validate( ... instance={"name" : "Eggs", "price" : "Invalid"}, schema=schema, ... ) # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... ValidationError: 'Invalid' is not of type 'number' It can also be used from the command line by installing check-jsonschema.
      » pip install jsonschema
    
Published   Jan 07, 2026
Version   4.26.0
🌐
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...
🌐
GitHub
github.com › python-jsonschema
Python + JSON Schema · GitHub
JSON Schema implementation and surrounding tooling for Python - Python + JSON Schema
🌐
PyPI
pypi.org › project › genson
genson · PyPI
GenSON is a powerful, user-friendly JSON Schema generator built in Python.
      » pip install genson
    
Published   May 15, 2024
Version   1.3.0
🌐
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.
🌐
Medium
medium.com › grammofy › handling-complex-json-schemas-in-python-9eacc04a60cf
Handling complex JSON Schemas in Python | by Paul Götze | Grammofy | Medium
August 21, 2020 - Handling complex JSON Schemas in Python In a previous post we looked at how to test your Python API app with JSON Schema. In case you have to deal with complex and nested JSON data, schema …
🌐
jsonschema
python-jsonschema.readthedocs.io › en › latest › referencing
JSON (Schema) Referencing - jsonschema 4.26.1.dev25+gad0a1b301 documentation
from referencing import Registry, Resource schema = Resource.from_contents( { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "integer", "minimum": 0, }, ) registry = Registry().with_resources( [ ("http://example.com/nonneg-int-schema", schema), ("urn:nonneg-integer-schema", schema), ], ) What’s above is likely mostly self-explanatory, other than the presence of the referencing.Resource.from_contents function. Its purpose is to convert a piece of “opaque” JSON (or really a Python dict containing deserialized JSON) into an object which indicates what version of JSON Schema the schema is meant to be interpreted under.
Top answer
1 of 5
39

So far the closest thing I've been able to find is warlock, which advertises this workflow:

Build your schema

>>> schema = {
    'name': 'Country',
    'properties': {
        'name': {'type': 'string'},
        'abbreviation': {'type': 'string'},
    },
    'additionalProperties': False,
}

Create a model

>>> import warlock
>>> Country = warlock.model_factory(schema)

Create an object using your model

>>> sweden = Country(name='Sweden', abbreviation='SE')

However, it's not quite that easy. The objects that Warlock produces lack much in the way of introspectible goodies. And if it supports nested dicts at initialization, I was unable to figure out how to make them work.

To give a little background, the problem that I was working on was how to take Chrome's JSONSchema API and produce a tree of request generators and response handlers. Warlock doesn't seem too far off the mark, the only downside is that meta-classes in Python can't really be turned into 'code'.

Other useful modules to look for:

  • jsonschema - (which Warlock is built on top of)
  • valideer - similar to jsonschema but with a worse name.
  • bunch - An interesting structure builder thats half-way between a dotdict and construct

If you end up finding a good one-stop solution for this please follow up your question - I'd love to find one. I poured through github, pypi, googlecode, sourceforge, etc.. And just couldn't find anything really sexy.

For lack of any pre-made solutions, I'll probably cobble together something with Warlock myself. So if I beat you to it, I'll update my answer. :p

2 of 5
28

python-jsonschema-objects is an alternative to warlock, build on top of jsonschema

python-jsonschema-objects provides an automatic class-based binding to JSON schemas for use in python.

Usage:

Sample Json Schema

schema = '''{
    "title": "Example Schema",
    "type": "object",
    "properties": {
        "firstName": {
            "type": "string"
        },
        "lastName": {
            "type": "string"
        },
        "age": {
            "description": "Age in years",
            "type": "integer",
            "minimum": 0
        },
        "dogs": {
            "type": "array",
            "items": {"type": "string"},
            "maxItems": 4
        },
        "gender": {
            "type": "string",
            "enum": ["male", "female"]
        },
        "deceased": {
            "enum": ["yes", "no", 1, 0, "true", "false"]
            }
    },
    "required": ["firstName", "lastName"]
} '''

Converting the schema object to class

 import python_jsonschema_objects as pjs
 import json
 schema = json.loads(schema)   
 builder = pjs.ObjectBuilder(schema)   
 ns = builder.build_classes()   
 Person = ns.ExampleSchema   
 james = Person(firstName="James", lastName="Bond")   
 james.lastName  
  u'Bond'  james      
 example_schema lastName=Bond age=None firstName=James  

Validation :

james.age = -2 python_jsonschema_objects.validators.ValidationError: -2 was less or equal to than 0

But problem is , it is still using draft4validation while jsonschema has moved over draft4validation , i filed an issue on the repo regarding this . Unless you are using old version of jsonschema , the above package will work as shown.

Find elsewhere
🌐
GitHub
github.com › jacksmith15 › statham-schema
GitHub - jacksmith15/statham-schema: Statham is a Python Model Parsing Library for JSON Schema.
statham is a Python Model Parsing Library for JSON Schema.
Starred by 38 users
Forked by 9 users
Languages   Python 98.4% | Shell 1.1% | Makefile 0.5% | Python 98.4% | Shell 1.1% | Makefile 0.5%
🌐
GitHub
github.com › python-jsonschema › jsonschema
GitHub - python-jsonschema/jsonschema: An implementation of the JSON Schema specification for Python · GitHub
>>> from jsonschema import validate >>> # A sample schema, like what we'd get from json.load() >>> schema = { ... "type" : "object", ... "properties" : { ... "price" : {"type" : "number"}, ... "name" : {"type" : "string"}, ... }, ... } >>> # If no exception is raised by validate(), the instance is valid. >>> validate(instance={"name" : "Eggs", "price" : 34.99}, schema=schema) >>> validate( ... instance={"name" : "Eggs", "price" : "Invalid"}, schema=schema, ...
Starred by 4.9K users
Forked by 609 users
Languages   Python 99.8% | TypeScript 0.2%
🌐
Pydantic
docs.pydantic.dev › latest › concepts › json_schema
JSON Schema - Pydantic Validation
This produces a "jsonable" dict of MainModel's schema. Calling json.dumps on the schema dict produces a JSON string.
🌐
GitHub
github.com › cwacek › python-jsonschema-objects
GitHub - cwacek/python-jsonschema-objects: Automatic Python binding generation from JSON Schemas · GitHub
These classes can seamlessly encode back and forth to JSON valid according to the schema. 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): ...
Starred by 373 users
Forked by 90 users
Languages   Python
🌐
Windmill
windmill.dev › json schema and parsing
JSON schema and parsing | Windmill
Scripts in Windmill have input parameters defined by a JSON Schema, where each parameter in the main function of a script corresponds to a field in the JSON Schema. This one-to-one correspondence ensures that the name of the argument becomes the name of the property, and most primitive types in Python and TypeScript have a corresponding primitive type in JSON and JSON Schema.
🌐
PyPI
pypi.org › project › jsonschema-rs
jsonschema-rs - A high-performance JSON Schema validator ...
A high-performance JSON Schema validator for Python
      » pip install jsonschema-rs
    
🌐
DEV Community
dev.to › stefanalfbo › python-json-schema-3o7n
Python JSON schema - DEV Community
May 9, 2024 - JSON Schema can be a great tool to document this contract, define constraints and validate the contract. In Python we can use the jsonschema library to enable the power of JSON Schema in our projects.
🌐
Built In
builtin.com › software-engineering-perspectives › python-json-schema
How to Use JSON Schema to Validate JSON Documents in Python | Built In
It supports nested objects, arrays, and uses $defs for reusable code. A Validator instance allows for efficient multi-document validation. In Python, the JSON Schema library can be used to validate a JSON document against a schema.
🌐
Donofden
donofden.com › blog › 2020 › 03 › 15 › How-to-Validate-JSON-Schema-using-Python
How to Validate JSON Schema using Python
Currently the most complete and compliant JSON Schema validator available for python is Jsonschema.
🌐
jsonschema
python-jsonschema.readthedocs.io › en › latest › validate
Schema Validation - jsonschema 4.26.1.dev25+gad0a1b301 documentation
Most of the documentation for this package assumes you’re familiar with the fundamentals of writing JSON schemas themselves, and focuses on how this library helps you validate with them in Python.
🌐
GeeksforGeeks
geeksforgeeks.org › python › introduction-to-python-jsonschema
Introduction to Python jsonschema - GeeksforGeeks
July 23, 2025 - It is widely used in APIs, configuration files, and data interchange formats to ensure that the data adheres to a defined standard. The jsonschema is a Python library used for validating JSON data against a schema.
🌐
Pythonrepo
pythonrepo.com › repo › Julian-jsonschema-python-data-validation
An(other) implementation of JSON Schema for Python | PythonRepo
Julian/jsonschema, jsonschema jsonschema is an implementation of JSON Schema for Python. >>> from jsonschema import validate >>> # A sample schema, like what we'd get f