Pydantic JSON Schema
Pydantic turns models into JSON Schema. This library does the reverse — it turns a JSON Schema into a Pydantic model, so you can validate data against a schema you already have, with all of Pydantic's runtime checks and editor support.
Reach for it when the schema comes first: API contracts, config files, tool definitions, or validating LLM output against a fixed shape.
Installation
uv add pydantic-jsonschema
Requires Python 3.12+. See the installation guide for optional validator libraries.
Quick start
from pydantic_jsonschema import Schema, to_model
schema = Schema.model_validate({
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer", "minimum": 0},
},
"required": ["name"],
})
User = to_model(schema, model_name="User")
user = User(name="Alice", age=30)
print(user.model_dump())
#> {'name': 'Alice', 'age': 30}
What's inside
Three building blocks — and a fourth on the way.
1. The schema model — Schema & Reference
A Pydantic model for JSON Schema itself: parse, inspect, and serialize schemas with full
type safety. $refs are parsed as Reference objects and resolved during conversion.
from pydantic_jsonschema import DataType, Schema
schema = Schema(
type=DataType.OBJECT,
properties={"name": Schema(type=DataType.STRING)},
required=["name"],
)
print(schema.model_dump_json())
#> {"type":"object","properties":{"name":{"type":"string"}},"required":["name"]}
2. The converter — to_model / SchemaConverter
Turns a Schema into a Pydantic model (see Quick start). It resolves
$ref / $defs, maps anyOf / oneOf (including discriminated unions) / allOf to
Python types, and applies string, number, array, and object constraints as Pydantic
validation.
3. Formats
Built-in types for every format in the JSON Schema spec (email, uri, uuid,
date-time, hostname, json-pointer, regex, and more) — with zero extra
dependencies. Map your own Pydantic type for custom formats.
from pydantic_jsonschema import Schema, to_model
from pydantic_jsonschema.formats import Email
schema = Schema.model_validate({
"type": "object",
"properties": {"email": {"type": "string", "format": "email"}},
"required": ["email"],
})
User = to_model(schema, formats={"email": Email})
print(User(email="alice@example.com").email)
#> alice@example.com
Planned: configurable loading by type
Per-object control over how each type is loaded, inspired by adaptix.
Documentation
https://danipulok.github.io/pydantic-jsonschema/
Acknowledgments
License
MIT License - see LICENSE for details.
Metadata
Release files for pydantic-jsonschema 0.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydantic_jsonschema-0.0.13.tar.gz | 38.8 kB | With provenance | Details for pydantic_jsonschema-0.0.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydantic_jsonschema-0.0.13-py3-none-any.whl | Python 3 | none | any | Details for pydantic_jsonschema-0.0.13-py3-none-any.whl |
Total release size: 92.9 kB
Release files / pydantic_jsonschema-0.0.13.tar.gz
| Download URL | pydantic_jsonschema-0.0.13.tar.gz |
|---|---|
| Size | 38.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a73ec3d365941db3395aba3b60933c6d9c5240e458a97b0e35760a8c4cf4549
|
|
BLAKE2b-256 checksum How to use checksums |
00b77da239b4526bf1eb3032e9ed19affd95147c7dcddaa5866f8c496948b1b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 25, 2026.
Transparency logRelease files / pydantic_jsonschema-0.0.13-py3-none-any.whl
| Download URL | pydantic_jsonschema-0.0.13-py3-none-any.whl |
|---|---|
| Size | 54.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f5b1656f66125dadaf505217d018e0888b8da02398cd36bb40109f34d236a4b
|
|
BLAKE2b-256 checksum How to use checksums |
f063c983ab5bca283540f1d42900a4190097c5f3afd04c0f04f7e9435901a8e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 25, 2026.
Transparency logSecurity for pydantic-jsonschema 0.0.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pydantic_jsonschema-0.0.13.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.