If you haven't check jsonschema library, it can be useful to validate data. JSON Schema is a way to describe the content of JSON. The library just uses the format to make validations based on the given schema.

I made a simple example from basic usage.

import json
from jsonschema import validate

# Describe what kind of json you expect.
schema = {
    "type" : "object",
    "properties" : {
        "description" : {"type" : "string"},
        "status" : {"type" : "boolean"},
        "value_a" : {"type" : "number"},
        "value_b" : {"type" : "number"},
    },
}

# Convert json to python object.
my_json = json.loads('{"description": "Hello world!", "status": true, "value_a": 1, "value_b": 3.14}')

# Validate will raise exception if given json is not
# what is described in schema.
validate(instance=my_json, schema=schema)

# print for debug
print(my_json)
Answer from T.Nylund on Stack Overflow
🌐
jsonschema
python-jsonschema.readthedocs.io › en › latest › validate
Schema Validation - jsonschema 4.26.1.dev25+gad0a1b301 documentation
If you aren’t already comfortable with writing schemas and need an introduction which teaches about JSON Schema the specification, you may find Understanding JSON Schema to be a good read! The simplest way to validate an instance under a given schema is to use the validate function. ...
Discussions

JSON Schema validation
I see schema, schema · PyPI I also see Schema Validation - jsonschema 4.17.4.dev60+g65afdce documentation I was using the 1st one, schema, and was trying to understand how to represent tuples and then realized, maybe I’m not using the “recommended one”. More on discuss.python.org
🌐 discuss.python.org
0
January 23, 2023
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
JSON deserializer and validator
You might like to be aware of "jsonpickle". I imagine you might want a more "language agnostic" json schema or one that is more reliable (though in practice I think the serialization will change any time soon. You should also be aware of json schemas in general https://json-schema.org/ and the similarity of this to some of WSDL/soap standards (though these use xml rather than json). I'm really not a fan of these and when I've been forced to play with them before they did not work that well. Things like this: https://github.com/Julian/jsonschema might be interesting It doesn't look like json schemata are designed for deserialization. More on reddit.com
🌐 r/Python
7
4
September 5, 2018
Struggling with 'jsonschema-2.6.0'. Cannot import name 'validate'
Hmmm good question. jsonschema 3.0.1 has a validate function, so I think there may be another issue. Do you have a folder or called jsonschema anywhere nearby? Try getting into the interactive terminal and trying: >>> import jsonschema >>> help(jsonchema) >>> jsonschema._version.__version__ >>> jsonschema.version >>> jsonschema.validate More on reddit.com
🌐 r/learnpython
10
1
December 11, 2018
🌐
Built In
builtin.com › software-engineering-perspectives › python-json-schema
How to Use JSON Schema to Validate JSON Documents in Python | Built In
In Python, we can use the JSON Schema library to validate a JSON document against a schema. ... Summary: The jsonschema library validates JSON data against schemas, utilizing keywords like type, properties, and required.
🌐
PyPI
pypi.org › project › jsonschema
jsonschema · PyPI
An implementation of JSON Schema validation for Python
      » pip install jsonschema
    
Published   Jan 07, 2026
Version   4.26.0
🌐
GitHub
github.com › python-jsonschema › jsonschema
GitHub - python-jsonschema/jsonschema: An implementation of the JSON Schema specification for Python · GitHub
>>> 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.
Starred by 4.9K users
Forked by 609 users
Languages   Python 99.8% | TypeScript 0.2%
🌐
GeeksforGeeks
geeksforgeeks.org › python › introduction-to-python-jsonschema
Introduction to Python jsonschema - GeeksforGeeks
July 23, 2025 - This example validates JSON data with a nested structure. The schema expects an object with a person property, which includes name and address (address itself is an object with street and city).
Find elsewhere
🌐
Soumendrak
soumendrak.com › blog › how-to-validate-a-json-in-python
Soumendra Kumar Sahoo • How to validate a JSON in Python
January 13, 2024 - from datetime import date from pydantic import BaseModel, ConfigDict, ValidationError class Event(BaseModel): model_config = ConfigDict(strict=True) when: date where: tuple[int, int] json_data = '{"when": "1987-01-28", "where": [51, -1]}' print(Event.model_validate_json(json_data)) #> when=datetime.date(1987, 1, 28) where=(51, -1) try: Event.model_validate({'when': '1987-01-28', 'where': [51, -1]}) except ValidationError as e: print(e) """ 2 validation errors for Event when Input should be a valid date [type=date_type, input_value='1987-01-28', input_type=str] where Input should be a valid tuple [type=tuple_type, input_value=[51, -1], input_type=list] """ ... JSONSchema validation is a powerful tool for validating JSON data.
🌐
jsonschema
python-jsonschema.readthedocs.io
jsonschema 4.26.0 documentation
>>> validate(instance={"name" : "Eggs", "price" : 34.99}, schema=schema) >>> validate( ... instance={"name" : "Eggs", "price" : "Invalid"}, schema=schema, ... ) 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.
🌐
Python.org
discuss.python.org › python help
JSON Schema validation - Python Help - Discussions on Python.org
January 23, 2023 - What is the recommended package to use for validating json data with a schema? I see schema, schema · PyPI I also see Schema Validation - jsonschema 4.17.4.dev60+g65afdce documentation I was using the 1st one, schema,…
🌐
LinkedIn
linkedin.com › pulse › mastering-json-schema-validation-python-developers-guide-singh-ebffc
Mastering JSON Schema Validation with Python: A Developer’s Guide
February 16, 2024 - When built-in validators don’t meet your needs, custom validators are your next step. Here’s a glimpse into creating a custom validator with jsonschema:
🌐
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. See some numbers: Probably the most popular, jsonschema, can take ...
🌐
DEV Community
dev.to › stefanalfbo › python-json-schema-3o7n
Python JSON schema - DEV Community
May 9, 2024 - import json from pathlib import Path import jsonschema import pytest from rest_framework.test import APIClient from django.contrib.auth.models import User @pytest.mark.django_db def test_get_user(): # Create a user _ = User.objects.create_user(username="test-user", email="test-user@example.com") client = APIClient() response = client.get('/users/1/') assert response.status_code == 200 # Load the JSON schema user_json_schema = Path(".") / "quickstart" / "json-schema" / "user.json" with open(user_json_schema) as schema_file: schema = json.load(schema_file) # Validate the response JSON against the schema jsonschema.validate(response.json(), schema)
🌐
Readthedocs
python-jsonschema.readthedocs.io › en › v4.8.0 › validate
Schema Validation - jsonschema 4.8.0 documentation
It is assumed to be valid, and providing an invalid schema can lead to undefined behavior. See Validator.check_schema to validate a schema first. resolver – an instance of jsonschema.RefResolver that will be used to resolve $ref properties (JSON references).
🌐
PyPI
pypi.org › project › jsonschema-rs
jsonschema-rs - A high-performance JSON Schema validator ...
A high-performance JSON Schema validator for Python. import jsonschema_rs schema = {"maxLength": 5} instance = "foo" # One-off validation try: jsonschema_rs.validate(schema, "incorrect") except jsonschema_rs.ValidationError as exc: assert str(exc) == '''"incorrect" is longer than 5 characters Failed validating "maxLength" in schema On instance: "incorrect"''' # Build & reuse (faster) validator = jsonschema_rs.validator_for(schema) # Iterate over errors for error in validator.iter_errors(instance): print(f"Error: {error}") print(f"Location: {error.instance_path}") # Boolean result assert validator.is_valid(instance) # Structured output (JSON Schema Output v1) evaluation = validator.evaluate(instance) for error in evaluation.errors(): print(f"Error at {error['instanceLocation']}: {error['error']}")
      » pip install jsonschema-rs
    
🌐
jsonschema
python-jsonschema.readthedocs.io › en › latest › errors
Handling Validation Errors - jsonschema 4.26.1.dev25+gad0a1b301 documentation
Each tree and child has a ErrorTree.errors attribute, a dict, that maps the failed validation keyword to the corresponding validation error. The best_match function is a simple but useful function for attempting to guess the most relevant error in a given bunch. >>> from jsonschema import Draft202012Validator >>> from jsonschema.exceptions import best_match >>> 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. :)

🌐
GitHub
github.com › python-jsonschema › check-jsonschema
GitHub - python-jsonschema/check-jsonschema: A CLI and set of pre-commit hooks for jsonschema validation with built-in support for GitHub Workflows, Renovate, Azure Pipelines, and more! · GitHub
The following configuration uses check-jsonschema to validate Github Workflow files. - repo: https://github.com/python-jsonschema/check-jsonschema rev: 0.37.0 hooks: - id: check-github-workflows args: ["--verbose"]
Starred by 300 users
Forked by 59 users
Languages   Python 99.8% | Just 0.2%
🌐
Donofden
donofden.com › blog › 2020 › 03 › 15 › How-to-Validate-JSON-Schema-using-Python
How to Validate JSON Schema using Python
import json import jsonschema from jsonschema import validate def get_schema(): """This function loads the given schema available""" with open('user_schema.json', 'r') as file: schema = json.load(file) return schema def validate_json(json_data): """REF: https://json-schema.org/ """ # Describe what kind of json you expect. execute_api_schema = get_schema() try: validate(instance=json_data, schema=execute_api_schema) except jsonschema.exceptions.ValidationError as err: print(err) err = "Given JSON data is InValid" return False, err message = "Given JSON data is Valid" return True, message # Convert json to python object.
🌐
JSON Schema Validator
jsonschemavalidator.net
JSON Schema Validator - Newtonsoft
An online, interactive JSON Schema validator. Supports JSON Schema Draft 3, Draft 4, Draft 6, Draft 7, Draft 2019-09 and Draft 2020-12.