json-schema-to-pydantic
A Python library for automatically generating Pydantic v2 models from JSON Schema definitions
What it is and what it does
json-schema-to-pydantic bridges JSON Schema and Pydantic by generating type-safe Pydantic v2 models directly from schema definitions. It handles the complexity of schema features—$ref resolution with circular reference detection, combiners like allOf/anyOf/oneOf, format validations (email, uri, uuid, date-time), and edge cases like underscore-prefixed fields common in OpenAPI specs—so you don't have to write model classes by hand.
The library exposes a simple `create_model()` function for straightforward cases and a lower-level `PydanticModelBuilder` for advanced scenarios where you need to inject predefined models or type aliases. It supports relaxed validation modes for schemas that omit type information, and it generates models with full type hints. The package requires Python 3.9+ and depends only on pydantic.
Use it for:
- Convert OpenAPI/Swagger specs to Pydantic models for API client or server validation
- Automatically generate data models from JSON Schema files in data pipelines
- Build form validators from schema definitions without manual model coding
- Validate incoming JSON payloads against a schema-derived Pydantic model
- Integrate schema-driven APIs with Python codebases that use Pydantic for type safety
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automatically generates Pydantic v2 models from JSON Schema definitions, handling references, combiners, validations, and format constraints.
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real problem—eliminating boilerplate when you already have a JSON Schema. It's especially valuable if you work with OpenAPI specs or schema-heavy APIs. The MIT license is permissive. The single dependency on pydantic is a strength, not a weakness, since pydantic is ubiquitous.
Install
json-schema-to-pydantic on PyPI
pip
pip install json-schema-to-pydanticuv
uv add json-schema-to-pydanticpoetry
poetry add json-schema-to-pydanticInstalling json-schema-to-pydantic
Before you install
Low friction: pure Python wheel with a single runtime dependency on pydantic. Active maintenance with recent commits and no known vulnerabilities.
License in practice
MIT license permits commercial and private use with minimal restrictions—suitable for most projects.
Quickstart
pip install json-schema-to-pydantic
from json_schema_to_pydantic import create_model
schema = {
"title": "User",
"type": "object",
"properties": {
"name": {"type": "string"},
"email": {"type": "string", "format": "email"}
},
"required": ["name", "email"]
}
UserModel = create_model(schema)
user = UserModel(name="John", email="john@example.com")
Verify before relying
- Performance characteristics with very large or deeply nested schemas
- Completeness of JSON Schema draft version support (draft 7, 2020-12, etc.)
- Behavior when predefined_models or predefined_refs contain conflicting definitions
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pydantic |
| Maintenance | actively maintained — 158 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,105,875/month — #3,293 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: json_schema_to_pydantic-0.4.11-py3-none-any.whl
Keywords: conversion, json-schema, pydantic, schema, validation
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
jsonschema-pydantic-converterConverts JSON Schema definitions to Pydantic v2…
permissive · top 15,000 on PyPI
jamboConverts JSON Schema definitions into Pydantic…
permissive · top 15,000 on PyPI
django-pydantic-fieldProvides type-safe Pydantic model schemas for…
permissive · top 5,000 on PyPI
redis-omRedis OM provides declarative object mapping…
permissive · top 15,000 on PyPI
turnkey-sdk-typesProvides generated Pydantic type definitions…
permissive · top 15,000 on PyPI
flask-pydantic-specAdds OpenAPI documentation generation and…
unclear · top 15,000 on PyPI
dydanticDynamically generates Pydantic models from JSON…
permissive · top 5,000 on PyPI
jsonschema-pydanticConverts JSON Schema definitions into Pydantic…
unclear · top 15,000 on PyPI
openapi-schema-pydanticProvides Pydantic classes that map to the…
permissive · top 5,000 on PyPI
openapi-pydanticProvides Pydantic-based classes that implement…
permissive · top 1,000 on PyPI