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
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.
🌐
JSON Formatter
jsonformatter.org › json-parser
JSON Parser Online to parse JSON
This Parse JSON Online tool is very powerful. This will show data in a tree view which supports image viewer on hover. It also validates your data and shows errors in great detail.
Discussions

Validate JSON data using python - Stack Overflow
I need to create a function that ... a python dict. It should check if all necessary fields are present in a json file and also validate the data types of those fields. I need to use try-catch. Could you provide some kind of snippets or examples that give me answers? ... If you haven't check jsonschema library, it can be useful to validate data. JSON Schema is a way to ... More on stackoverflow.com
🌐 stackoverflow.com
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
A good schema validator?
I like pydantic because of the use of type annotations. More on reddit.com
🌐 r/Python
8
2
January 1, 2019
Fast JSON Schema for Python

Would you recommend your implementation over the alternatives even for cases that don't need the boost in performance? What are the differences in provided functionality? How is the stability? Any major features/changes still in the works?

More on reddit.com
🌐 r/Python
22
37
August 17, 2017
People also ask

My JSON has errors - can this tool validate and fix malformed JSON?
Yes! The tool includes a robust JSON validator that shows exactly where syntax errors occur with line numbers and context. It can auto-fix common issues like missing commas, trailing commas, unquoted keys, and improperly escaped characters even in deeply nested structures. The validator works at all nesting levels.
🌐
jsontotable.org
jsontotable.org
JSON to Table Converter - Convert Complex Nested JSON to HTML Table ...
Can I convert API response JSON to HTML table with nested objects?
Yes! The tool is designed specifically for API responses from REST APIs, GraphQL endpoints, and microservices. It handles nested objects, arrays, and complex hierarchical data structures automatically. Simply paste your API response, and it will create organized tables with sub-tables for nested data.
🌐
jsontotable.org
jsontotable.org
JSON to Table Converter - Convert Complex Nested JSON to HTML Table ...
How do I visualize nested JSON data as a tree structure online?
Paste your nested JSON into the converter, and it automatically creates a hierarchical tree structure view. You can expand and collapse nested objects and arrays to navigate through multiple levels of data. The tree visualization makes it easy to understand complex parent-child relationships in deeply nested JSON structures.
🌐
jsontotable.org
jsontotable.org
JSON to Table Converter - Convert Complex Nested JSON to HTML Table ...
🌐
Donofden
donofden.com › blog › 2020 › 03 › 15 › How-to-Validate-JSON-Schema-using-Python
How to Validate JSON Schema using Python
March 15, 2020 - Currently the most complete and compliant JSON Schema validator available for python is Jsonschema.
🌐
Medium
baoshangu.medium.com › json-schema-and-validation-with-python-ebeeae99d4a8
JSON schema and validation with Python | by Baoshan Gu | Medium
April 3, 2022 - With the schema, the data {“country”: “USA”, “states”: [“VA”, “BC”]} will get schema validation error: ‘BC’ is not one of [‘CA’, ‘TX’, ‘VA’]. The JSON data {“country”: “USA”, “states”: [“CA”, “VA”]} will be valid. The article provides several basic JSON schema use cases. For multiple conditions or complicated cases, you might need to use combinations of allOf, oneOf, anyOf, not and required etc checks. And for each of the use cases, there are probably many other ways to define a schema. https://json-schema.org/understanding-json-schema/reference/conditionals.html · https://python-jsonschema.readthedocs.io/en/stable/
🌐
Horejsek
horejsek.github.io › python-fastjsonschema
Fast JSON schema for Python — fastjsonschema documentation
Generates validation function for validating JSON schema passed in definition.
Find elsewhere
🌐
Jsontotable
jsontotable.org
JSON to Table Converter - Convert Complex Nested JSON to HTML Table Online
Yes! The tool includes a robust JSON validator that shows exactly where syntax errors occur with line numbers and context. It can auto-fix common issues like missing commas, trailing commas, unquoted keys, and improperly escaped characters even ...
🌐
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%
🌐
jsonschema
python-jsonschema.readthedocs.io › en › stable › creating
Creating or Extending Validator Classes - jsonschema 4.26.0 documentation
If unprovided, a jsonschema.FormatChecker will be created with a set of default formats typical of JSON Schema drafts. id_of – A function that given a schema, returns its ID. applicable_validators – A function that, given a schema, returns the list of applicable schema keywords and associated values which will be used to validate the instance.
🌐
Pydantic
docs.pydantic.dev › latest
Welcome to Pydantic - Pydantic Validation
Powered by type hints — with Pydantic, schema validation and serialization are controlled by type annotations; less to learn, less code to write, and integration with your IDE and static analysis tools. Learn more… · Speed — Pydantic's core validation logic is written in Rust. As a result, Pydantic is among the fastest data validation libraries for Python. Learn more… · JSON Schema — Pydantic models can emit JSON Schema, allowing for easy integration with other tools.
🌐
Claude API Docs
platform.claude.com › docs › en › build-with-claude › structured-outputs
Structured outputs - Claude API Docs
Include the output_config.format parameter in your API request with type: "json_schema" and your schema definition. ... Claude's response is valid JSON matching your schema, returned in response.content[0].text.
🌐
Pydantic
docs.pydantic.dev › latest › concepts › json_schema
JSON Schema - Pydantic Validation
Calling json.dumps on the schema dict produces a JSON string. The TypeAdapter class lets you create an object with methods for validating, serializing, and producing JSON schemas for arbitrary types.
🌐
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
🌐
FastAPI
fastapi.tiangolo.com › tutorial › body
Request Body - FastAPI
With just that Python type declaration, FastAPI will: Read the body of the request as JSON. Convert the corresponding types (if needed). Validate the data.
🌐
Couchbase
couchbase.com › home › validate json documents in python using pydantic
JSON Validation Against Pydantic Schema Tutorial | Couchbase
June 14, 2025 - This user profile example shows how we can easily create custom schemas for our JSON documents. This post also shows how to use the test and validate capabilities of Python and the pydantic module.
🌐
DEV Community
dev.to › sanskar_4862 › validating-json-schema-with-fixed-and-user-defined-keys-in-python-34ej
Validating JSON Schema with Fixed and User-Defined Keys in Python - DEV Community
November 11, 2024 - To validate these structures, the schema uses patternProperties, which allows for flexible keys that match a predefined pattern (e.g., keys starting with customField_ followed by a digit).
🌐
Google AI
ai.google.dev › gemini api › structured outputs
Structured outputs | Gemini API | Google AI for Developers
January 12, 2026 - To generate a JSON object, set the response_mime_type in the generation configuration to application/json and provide a response_json_schema. The schema must be a valid JSON Schema that describes the desired output format.
🌐
PyPI
pypi.org › project › jsonschema-rs
jsonschema-rs - A high-performance JSON Schema validator ...
Custom keywords are classes that receive the keyword value during schema compilation and validate instances at runtime: import jsonschema_rs class DivisibleBy: def __init__(self, parent_schema, value, schema_path): self.divisor = value def validate(self, instance): if isinstance(instance, int) and instance % self.divisor != 0: raise ValueError(f"{instance} is not divisible by {self.divisor}") validator = jsonschema_rs.validator_for( {"type": "integer", "divisibleBy": 3}, keywords={"divisibleBy": DivisibleBy}, ) validator.is_valid(9) # True validator.is_valid(10) # False
      » pip install jsonschema-rs
    
🌐
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. :)