Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.

>>> from jsonschema import validate

>>> # A sample schema, like what we'd get from json.load()
>>> schema = {
...     "type" : "object",
...     "properties" : {
...         "price" : {"type" : "number"},
...         "name" : {"type" : "string"},
...     },
... }

>>> # If no exception is raised by validate(), the instance is valid.
>>> 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.

Features

Installation

jsonschema is available on PyPI. You can install using pip:

$ pip install jsonschema

Extras

Two extras are available when installing the package, both currently related to format validation:

  • format

  • format-nongpl

They can be used when installing in order to include additional dependencies, e.g.:

$ pip install jsonschema'[format]'

Be aware that the mere presence of these dependencies – or even the specification of format checks in a schema – do not activate format checks (as per the specification). Please read the format validation documentation for further details.

About

I’m Julian Berman.

jsonschema is on GitHub.

Get in touch, via GitHub or otherwise, if you’ve got something to contribute, it’d be most welcome!

You can also generally find me on Libera (nick: Julian) in various channels, including #python.

If you feel overwhelmingly grateful, you can also sponsor me.

And for companies who appreciate jsonschema and its continued support and growth, jsonschema is also now supportable via TideLift.

Release Information

v4.18.0

This release majorly rehaul’s the way in which JSON Schema reference resolution is configured. It does so in a way that should be backwards compatible, preserving old behavior whilst emitting deprecation warnings.

  • jsonschema.RefResolver is now deprecated in favor of the new referencing library. referencing will begin in beta, but already is more compliant than the existing $ref support. This change is a culmination of a meaningful chunk of work to make $ref resolution more flexible and more correct. Backwards compatibility should be preserved for existing code which uses RefResolver, though doing so is again now deprecated, and all such use cases should be doable using the new APIs. Please file issues on the referencing tracker if there is functionality missing from it, or here on the jsonschema issue tracker if you have issues with existing code not functioning the same, or with figuring out how to change it to use referencing.

  • Support for Python 3.7 has been dropped, as it is nearing end-of-life. This should not be a “visible” change in the sense that requires-python has been updated, so users using 3.7 should still receive v4.17.3 when installing the library.

  • On draft 2019-09, unevaluatedItems now properly does not consider items to be evaluated by an additionalItems schema if items is missing from the schema, as the specification says in this case that additionalItems must be completely ignored.

  • Fix the date format checker on Python 3.11 (when format assertion behavior is enabled), where it was too liberal (#1076).

  • Speed up validation of unevaluatedProperties (#1075).

Deprecations

  • jsonschema.RefResolver – see above for details on the replacement

  • jsonschema.RefResolutionError – see above for details on the replacement

  • importing jsonschema.ErrorTree – instead import it via jsonschema.exceptions.ErrorTree

  • importing jsonschema.FormatError – instead import it via jsonschema.exceptions.FormatError

Release files for jsonschema 4.18.0a4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonschema 4.18.0a4
File Size Uploaded
jsonschema-4.18.0a4.tar.gz 310.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonschema 4.18.0a4
File Interpreter ABI Platform
jsonschema-4.18.0a4-py3-none-any.whl Python 3 none any Details

Total release size: 390.8 kB

Release files / jsonschema-4.18.0a4.tar.gz

Download URL jsonschema-4.18.0a4.tar.gz
Size 310.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7f6b40b7501c770ab1465e0f91b0b3737351d9b488331ab39ad0b6aa9869c39e
BLAKE2b-256 checksum
How to use checksums
9ac2e07414856007fe3102170e10b9c8310c79d614fdb7af7288450ac88d57a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / jsonschema-4.18.0a4-py3-none-any.whl

Download URL jsonschema-4.18.0a4-py3-none-any.whl
Size 80.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4abe05b475016459cafb5520fb2062a923adf72aa8ad1319d8a92fa227cf59b
BLAKE2b-256 checksum
How to use checksums
a1e9b4fa27cb825b2f7b3daa58691e749415add98f8544d5501d246273a01da7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release history Release notifications | RSS feed

4.25.1

2 release files

4.25.0

2 release files

4.24.1

2 release files

4.24.0

2 release files

4.22.0

2 release files

4.21.1

2 release files

4.21.0

2 release files

4.20.0

2 release files

4.19.2

2 release files

4.19.1

2 release files

4.18.4

2 release files

4.18.3

2 release files

4.18.2

2 release files

4.18.1

2 release files

This release

4.18.0a4 This release

2 release files

4.17.3

2 release files

4.17.1

2 release files

4.15.0

2 release files

4.14.0

2 release files

4.13.0

2 release files

4.12.1

2 release files

4.12.0

2 release files

4.11.0

2 release files

4.10.3

2 release files

4.10.2

2 release files

4.10.1

2 release files

4.10.0

2 release files

4.9.1

2 release files

4.9.0

2 release files

4.8.0

2 release files

4.7.2

2 release files

4.7.1

2 release files

4.7.0

2 release files

4.6.2

2 release files

4.6.1

2 release files

4.6.0

2 release files

4.5.1

2 release files

4.5.0

2 release files

4.4.0

2 release files

4.3.3

2 release files

4.3.2

2 release files

4.3.1

2 release files

4.3.0

2 release files

4.2.1

2 release files

4.2.0

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.6.0

2 release files

2.5.1

3 release files

2.5.0

2 release files

2.4.0

3 release files

2.3.0

3 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.8.0

2 release files

0.7

2 release files

0.6

2 release files

0.5

2 release files

0.4

2 release files

0.3

2 release files

0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page