--- id: json-schema-to-pydantic version: "0.4.11" license: MIT license_treatment: permissive maintenance: active --- # json-schema-to-pydantic — A Python library for automatically generating Pydantic v2 models from JSON Schema definitions License: permissive · Maintenance: active · Downloads: 2.1M/mo ## 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 above — 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 pip install json-schema-to-pydantic uv add json-schema-to-pydantic poetry add json-schema-to-pydantic ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 2.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags json schema to pydantic, generate pydantic models from schema, json schema validation, pydantic model generation, schema to python models, openapi to pydantic, json schema converter, schema-generation, openapi, data-validation [View on SkillFed](https://skillfed.io/packages/json-schema-to-pydantic) · [View on PyPI](https://pypi.org/project/json-schema-to-pydantic/)