skillfed

jsonschema-pydantic-converter

Convert JSON Schema definitions to Pydantic models dynamically at runtime

jsonschema-pydantic-converter v0.4.0 314.0K downloads/30d#7,708 on PyPI5
Permissive license Apache-2.0 Active released

What it is and what it does

jsonschema-pydantic-converter bridges JSON Schema and Pydantic by transforming JSON Schema dictionaries into Pydantic v2 models or TypeAdapters at runtime. This is useful when you work with dynamic or externally-defined schemas—for example, when validating data against a JSON Schema specification that you don't know until runtime, or when integrating systems that use JSON Schema with Pydantic-based applications.

The library handles a broad range of JSON Schema constructs: primitive types, arrays, nested objects, enums, union types (anyOf, oneOf), combined schemas (allOf), negation, constant values, and schema references ($ref, $defs). It preserves validation constraints like string length and pattern rules, numeric bounds, and array size limits. It also handles reserved Pydantic property names by renaming them internally while preserving the original JSON names through aliases.

Use it for:

  • Validate incoming API payloads against a JSON Schema specification without manually writing Pydantic models.
  • Build schema-driven applications where the data model is defined externally or loaded from configuration files.
  • Bridge legacy JSON Schema-based systems with modern Pydantic-based codebases.
  • Generate TypeAdapters for direct JSON string validation and serialization without intermediate model definitions.
  • Handle dynamic or user-provided schemas in data processing pipelines where models cannot be hardcoded.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Converts JSON Schema definitions to Pydantic v2 models at runtime, enabling dynamic validation and serialization of data against JSON Schema specifications.

Yes, with conditions. Install if you need to work with dynamic JSON Schemas and want Pydantic validation without writing models by hand. The library is actively maintained, has no known vulnerabilities, and low install friction. However, it is in Alpha status (first release 2025-11-12), so expect potential API changes and test thoroughly before using in production.

Install

jsonschema-pydantic-converter on PyPI

pip

pip install jsonschema-pydantic-converter

uv

uv add jsonschema-pydantic-converter

poetry

poetry add jsonschema-pydantic-converter

Installing jsonschema-pydantic-converter

Before you install

Low install friction with a single runtime dependency on pydantic. Active maintenance with recent commits and no known vulnerabilities. Early-stage project (Alpha status, first release 2025-11-12) but receiving regular updates.

License in practice

Apache-2.0 permissive license allows commercial and private use with minimal restrictions; you must include a copy of the license and state significant changes.

Quickstart

from jsonschema_pydantic_converter import create_type_adapter

schema = {
    "type": "object",
    "properties": {"name": {"type": "string"}, "age": {"type": "integer"}},
    "required": ["name"]
}
adapter = create_type_adapter(schema)
user = adapter.validate_python({"name": "John", "age": 30})

Requires Python 3.10 or later and pydantic as a runtime dependency.

Verify before relying

  • Performance characteristics when converting large or deeply nested schemas at runtime.
  • Completeness of JSON Schema draft support (which draft versions are fully covered).
  • Behavior with circular or mutually recursive schema definitions beyond stated self-reference support.
  • Real-world production stability given Alpha status and limited adoption signals.

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 1 — pydantic
Maintenance actively maintained — 142 days since the last release
Last repo commit
First released
Downloads 313,993/month — #7,708 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: jsonschema_pydantic_converter-0.4.0-py3-none-any.whl

Keywords: conversion, json-schema, pydantic, schema, validation

Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Software Development :: Libraries :: Python Modules

Tags

json schema to pydantic modeldynamic pydantic model generationjson schema validation pydanticconvert json schema runtimepydantic type adapter from schemajson schema bridge pydanticschema-driven model creation
schema-validationjson-schemadynamic-models

More Python Modules packages