That's precisely how schemas are validated! Download the meta-schema (declared in the $schema keyword) and validate the schema against the meta-schema. It's designed to do this.

Answer from gregsdennis on Stack Overflow
🌐
jsonschema
python-jsonschema.readthedocs.io › en › stable › validate
Schema Validation - jsonschema 4.26.0 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. ...
🌐
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.
🌐
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
🌐
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.
🌐
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. ...
🌐
PYnative
pynative.com › home › python › json › validate json data using python
Validate JSON data using Python
May 14, 2021 - Using jsonschema, we can create a schema of our choice, so every time we can validate the JSON document against this schema, if it passed, we could say that the JSON document is valid.
🌐
Programster
blog.programster.org › python-validate-json
Python - Validate JSON | Programster's Blog
March 5, 2022 - The snippet below shows you how you can validate a JSON file against a JSON schema. ... import json import jsonschema # A sample schema, like what we'd get from json.load() with open('schema.json') as schemaFile: schema = json.load(schemaFile) jsonschema.Draft7Validator.check_schema(schema) print("Schema is valid") with open('data.json') as dataFile: data = json.load(dataFile) validator = jsonschema.Draft7Validator(schema).validate(data) # Wont get to here if validation fails, as will throw exception print("Validation passed.")
Find elsewhere
🌐
Towards Data Science
towardsdatascience.com › home › latest › how to use json schema to validate json documents in python
How to Use JSON Schema to Validate JSON Documents in Python | Towards Data Science
March 5, 2025 - In Python, we can use the jsonschema library to validate a JSON instance (can also be referred to as JSON document as long as it’s unambiguous) against a 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).
🌐
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 610 users
Languages   Python 99.8% | TypeScript 0.2%
🌐
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)
🌐
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
    
🌐
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.
🌐
GitHub
github.com › donofden › python-validate-json-schema
GitHub - donofden/python-validate-json-schema: Validate JSON Schema using Python
This is a helper project for JSON Schema validation in Python, which uses Jsonschema the most complete and compliant JSON Schema validator.
Starred by 6 users
Forked by 2 users
Languages   Python 100.0% | Python 100.0%
🌐
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).
🌐
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:
🌐
jsonschema
python-jsonschema.readthedocs.io › en › v4.18.0 › validate
Schema Validation - jsonschema 4.18.0 documentation
If you aren’t already comfortable ... a good read! The simplest way to validate an instance under a given schema is to use the validate function. jsonschema.validate(instance, schema, cls=None, *args, **kwargs)[source...