๐ŸŒ
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...
๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ jsonschema
jsonschema - JSON Schema validation for Python
An implementation of JSON Schema validation for Python
      ยป pip install jsonschema
    
Published ย  Jan 07, 2026
Version ย  4.26.0
Discussions

I wrote okjson - A fast, simple, and pythonic JSON Schema Validator
https://github.com/mufeedvh/okjson/blob/main/okjson/validator.py It's useful to use a formatter/linter and configure your text editor to be aligned with the linter. $> pylint okjson | grep 'Bad indentation' | wc -l 100 black is a popular formatter used by the community. https://github.com/psf/black pylint is a useful listing tool. https://pylint.pycqa.org/en/latest/ Best of luck to you on your project. More on reddit.com
๐ŸŒ r/Python
4
14
March 31, 2022
Convert a JSON schema to a python class - Stack Overflow
Is there a python library for converting a JSON schema to a python class definition, similar to jsonschema2pojo -- https://github.com/joelittlejohn/jsonschema2pojo -- for Java? More on stackoverflow.com
๐ŸŒ stackoverflow.com
multi agent - Generate a JSON Schema specification from Python classes - Stack Overflow
Introduction Hello everyone ! I am trying to develop multi-agent models in Python3. So my approach is to create basic classes and derive them to more concrete and specific ones. For instance, a class More on stackoverflow.com
๐ŸŒ stackoverflow.com
How I Learned to Stop Worrying and Love JSON Schema

Pretty convincing. I'll give it a try sometime.

More on reddit.com
๐ŸŒ r/Python
3
8
October 28, 2014
๐ŸŒ
Pydantic
docs.pydantic.dev โ€บ latest โ€บ concepts โ€บ json_schema
JSON Schema - Pydantic Validation
Specify the mode of JSON schema generation via the mode parameter in the model_json_schema and TypeAdapter.json_schema methods. By default, the mode is set to 'validation', which produces a JSON schema corresponding to the model's validation schema. The JsonSchemaMode is a type alias that represents the available options for the mode parameter:
๐ŸŒ
GitHub
github.com โ€บ python-jsonschema
Python + JSON Schema ยท GitHub
JSON Schema implementation and surrounding tooling for Python - Python + JSON Schema
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
Reddit
reddit.com โ€บ r/python โ€บ i wrote okjson - a fast, simple, and pythonic json schema validator
r/Python on Reddit: I wrote okjson - A fast, simple, and pythonic JSON Schema Validator
March 31, 2022 -

I had a requirement to process and validate large payloads of JSON concurrently for a web service, initially I implemented it using jsonschema and fastjsonschema but I found the whole JSON Schema Specification to be confusing at times and on top of that wanted better performance. Albeit there are ways to compile/cache the schema, I wanted to move away from the schema specification so I wrote a validation library inspired by the design of tiangolo/sqlmodel (type hints) to solve this problem easier.

Here is a simple example:

from okjson import JSONValidator

schema = { 'name': str, 'age': int }

json_string = '{ "name": "Charly Gordon", "age": 32 }'

assert JSONValidator().is_valid(instance=json_string, schema=schema)

There is an example covering all the features in the README.

It also has well defined exceptions for each error case when you want to get the reason for the validation failure. (Helpful when you want to show user facing error messages)

GitHub: https://github.com/mufeedvh/okjson

This is my first time publishing a Python library, please share your feedback/suggestions. :)

Find elsewhere
๐ŸŒ
JSON Schema
json-schema.org โ€บ tools
JSON Schema - Tools
Bowtie is a meta-validator for JSON Schema implementations and it provides compliance reports.
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ json.html
json โ€” JSON encoder and decoder
3 weeks ago - The old version of JSON specified by the obsolete RFC 4627 required that the top-level value of a JSON text must be either a JSON object or array (Python dict or list), and could not be a JSON null, boolean, number, or string value.
๐ŸŒ
Medium
medium.com โ€บ @erick.peirson โ€บ type-checking-with-json-schema-in-python-3244f3917329
Type checking with JSON Schema in Python | by Erick Peirson | Medium
April 26, 2019 - Most notably, JSON Schema tends toward open-ended-ness, asserting constraints on data rather than providing a complete description. Unless specifically prohibited, a document may go beyond the specific properties enumerated in its schema. Type annotations in Python come down across the spectrum, ranging from permissive approaches like structural duck typing with Protocols (PEP 544) on one end to approaches like TypedDict that provide a complete and total description.
๐ŸŒ
FreshPorts
freshports.org โ€บ devel โ€บ py-jsonschema
FreshPorts -- devel/py-jsonschema: JSON Schema validation for Python
jsonschema is an implementation of JSON Schema for Python - Full support for Draft 3 and Draft 4 of the schema. - Lazy validation that can iteratively report all validation errors. - Small and extensible - Programmatic querying of which properties or items failed validation.
๐ŸŒ
GitHub
github.com โ€บ Stranger6667 โ€บ jsonschema
GitHub - Stranger6667/jsonschema: A high-performance JSON Schema validator for Rust ยท GitHub
use serde_json::json; fn main() -> Result<(), Box<dyn std::error::Error>> { let schema = json!({"maxLength": 5}); let instance = json!("foo"); // One-off validation assert!(jsonschema::is_valid(&schema, &instance)); assert!(jsonschema::validate(&schema, &instance).is_ok()); // Build & reuse (faster) let validator = jsonschema::validator_for(&schema)?; // Fail on first error assert!(validator.validate(&instance).is_ok()); // Iterate over errors for error in validator.iter_errors(&instance) { eprintln!("Error: {error}"); eprintln!("Location: {}", error.instance_path()); } // Boolean result assert!(validator.is_valid(&instance)); // Structured output (JSON Schema Output v1) let evaluation = validator.evaluate(&instance); for annotation in evaluation.iter_annotations() { eprintln!( "Annotation at {}: {:?}", annotation.schema_location, annotation.annotations.value() ); } Ok(()) }
Starred by 756 users
Forked by 120 users
Languages ย  Rust 88.7% | Python 6.6% | Ruby 4.4%
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.

๐ŸŒ
Stackademic
blog.stackademic.com โ€บ mastering-json-schema-validation-with-python-a-developers-guide-0bbf25513630
Mastering JSON Schema Validation with Python: A Developerโ€™s Guide | by Utkarsh Singh | Stackademic
February 16, 2024 - JSON Schema sets the stage by defining the acceptable data types (like strings, integers, arrays) and structures (such as specific properties within objects). It provides a comprehensive guide for shaping your JSON data.
๐ŸŒ
GitHub
github.com โ€บ python-jsonschema โ€บ jsonschema-specifications
GitHub - python-jsonschema/jsonschema-specifications: Support files exposing JSON from the JSON Schema specifications to Python
JSON support files from the JSON Schema Specifications (metaschemas, vocabularies, etc.), packaged for runtime access from Python as a referencing-based Schema Registry.
Starred by 12 users
Forked by 11 users
Languages ย  Python 100.0% | Python 100.0%
๐ŸŒ
Plain English
python.plainenglish.io โ€บ json-schema-a-practical-python-library-2a8ab08a4d3f
JSON schema, a practical Python library! | by Beck Moulton | Python in Plain English
November 18, 2024 - jsonschemaIt is a Python library used for validating JSON data structures. Based on the JSON Schema standard, it can effectively define and validate the structure of JSON data, thereby helping developers avoid errors and improve the reliability of data processing.
๐ŸŒ
JSON Schema
json-schema.org
JSON Schema
While JSON is probably the most popular format for exchanging data, JSON Schema is the vocabulary that enables JSON data consistency, validity, and interoperability at scale.
Top answer
1 of 1
1

Pydantic can help you achieve this:

Example from the Pydantic documentation

from enum import Enum
from pydantic import BaseModel, Field


class FooBar(BaseModel):
    count: int
    size: float = None


class Gender(str, Enum):
    male = 'male'
    female = 'female'
    other = 'other'
    not_given = 'not_given'


class MainModel(BaseModel):
    """
    This is the description of the main model
    """

    foo_bar: FooBar = Field(...)
    gender: Gender = Field(None, alias='Gender')
    snap: int = Field(
        42,
        title='The Snap',
        description='this is the value of snap',
        gt=30,
        lt=50,
    )

    class Config:
        title = 'Main'


# this is equivalent to json.dumps(MainModel.schema(), indent=2):
print(MainModel.schema_json(indent=2))

Output:

# this is equivalent to json.dumps(MainModel.schema(), indent=2):
print(MainModel.schema_json(indent=2))

{
  "title": "Main",
  "description": "This is the description of the main model",
  "type": "object",
  "properties": {
    "foo_bar": {
      "$ref": "#/definitions/FooBar"
    },
    "Gender": {
      "$ref": "#/definitions/Gender"
    },
    "snap": {
      "title": "The Snap",
      "description": "this is the value of snap",
      "default": 42,
      "exclusiveMinimum": 30,
      "exclusiveMaximum": 50,
      "type": "integer"
    }
  },
  "required": [
    "foo_bar"
  ],
  "definitions": {
    "FooBar": {
      "title": "FooBar",
      "type": "object",
      "properties": {
        "count": {
          "title": "Count",
          "type": "integer"
        },
        "size": {
          "title": "Size",
          "type": "number"
        }
      },
      "required": [
        "count"
      ]
    },
    "Gender": {
      "title": "Gender",
      "description": "An enumeration.",
      "enum": [
        "male",
        "female",
        "other",
        "not_given"
      ],
      "type": "string"
    }
  }
}
๐ŸŒ
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.
๐ŸŒ
GitConnected
levelup.gitconnected.com โ€บ building-an-ai-agent-from-scratch-with-pure-python-7d4532202637
Building an AI Agent from Scratch with pure Python | by Christian Bernecker | Feb, 2026 | Level Up Coding
1 month ago - To truly master AI, you need to build one from the ground up using raw Python and direct API calls. ... In this guide, we will build a Structured Plan-and-Execute Agent. While often grouped under the โ€œReActโ€ umbrella, this architecture is more robust for complex workflows because it breaks down a query into a JSON-based task list before execution.