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. ...
🌐
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.")
🌐
jsonschema
python-jsonschema.readthedocs.io › en › stable › api
API Reference - jsonschema 4.25.1 documentation
The main functionality is provided by the validator classes for each of the supported JSON Schema versions. Most commonly, jsonschema.validators.validate is the quickest way to simply validate a given instance under a schema, and will create a validator for you.
🌐
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.
🌐
PYnative
pynative.com › home › python › json › validate json data using python
Validate JSON data using Python
May 14, 2021 - Pass resultant JSON to validate() method of a jsonschema. This method will raise an exception if given json is not what is described in the schema. Let’s see the example. In this example, I am validating student JSON.
🌐
FastAPI
fastapi.tiangolo.com › features
Features - FastAPI
November 30, 2018 - This also means that in many cases you can pass the same object you get from a request directly to the database, as everything is validated automatically. The same applies the other way around, in many cases you can just pass the object you get from the database directly to the client. With FastAPI you get all of Pydantic's features (as FastAPI is based on Pydantic for all the data handling): ... No new schema definition micro-language to learn. If you know Python types you know how to use Pydantic.
Find elsewhere
🌐
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)
🌐
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.
🌐
Rad's blog
lat.sk › home › jsonchema: custom type, format and validator in python
jsonchema: Custom type, format and validator in Python » Rad's blog
February 24, 2024 - def is_positive(validator, value, instance, schema): if not isinstance(instance, Number): yield ValidationError("%r is not a number" % instance) def is_positive(validator, value, instance, schema): if not isinstance(instance, Number): yield ValidationError("%r is not a number" % instance) if value and instance <= 0: yield ValidationError("%r is not positive integer" % (instance,)) elif not value and instance > 0: yield ValidationError("%r is not negative integer nor zero" % (instance,)) A vali­da­tor must yield a Vali­dati­o­nError when the vali­dati­on fails. You can get inspi­red in jsonschema._validators.
🌐
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
🌐
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.
🌐
Libraries.io
libraries.io › conda › jsonschema
jsonschema 4.25.1 on conda - Libraries.io - security & maintenance data for open source software
>>> 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.
🌐
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).
🌐
kontrolissues
kontrolissues.net › 2017 › 05 › 16 › using-jsonschema-to-validate-input
Using JSONSchema to Validate input – kontrolissues
May 16, 2017 - Hopefully this post will help others start to think more about validating input and output of these APIs, or at the very least, spend just a little more time thinking about testing your API interactions before you decide to automate the massive explosion of your infrastructure with a poorly tested script. 🙂 · I’m assuming that you already know what JSON is, so let’s skip directly to talking about JsonSchema. This is a pythonlibrary which allows you to take your input/output and verify it against a known schema which defined the data types you’re expecting to see.
🌐
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%
🌐
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. ...
🌐
SOOS
app.soos.io › research › packages › Python › - › jsonschema-extended
Python's jsonschema-extended - SOOS
SOOS • Don't get cocky with your app sec. Industry leading app sec, all in one dashboard.