jsonschema-gentypes
Tool to generate Python types based on TypedDict from a JSON Schema
What it is and what it does
jsonschema-gentypes is a command-line tool that reads JSON Schema files and generates Python source code containing TypedDict type definitions. It bridges the gap between schema-first API design and Python's static type system, letting you define your data contracts once in JSON Schema and automatically produce typed Python code that can be validated against those schemas.
The tool supports both standard JSON Schema and OpenAPI3 schemas, automatically detecting which format you're using. It integrates with code formatters like black and isort, can be run as a pre-commit hook, and exports default values from the schema so you can use them in your Python code. It requires Python 3.10 or later and depends on jsonschema, PyYAML, requests, referencing, typing-extensions, and urllib3.
Use it for:
- Generate type-safe request/response models from an OpenAPI3 specification for use in web frameworks like Pyramid or FastAPI.
- Maintain a single JSON Schema as the source of truth for data validation while keeping Python types automatically in sync.
- Integrate schema-driven code generation into CI/CD pipelines via pre-commit hooks to catch type mismatches early.
- Build strongly-typed data validation layers in microservices without manually writing TypedDict classes.
- Generate Python types from shared JSON Schema definitions across multiple services or repositories.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates Python TypedDict types from JSON Schema definitions, with support for OpenAPI3 schemas and automatic code formatting.
Yes. The package is actively maintained, has no known vulnerabilities, uses a permissive license, and solves a real problem for teams using schema-first API design. Install friction is low and it integrates well into existing workflows via CLI, config files, and pre-commit hooks. Suitable for production use.
Install
jsonschema-gentypes on PyPI
pip
pip install jsonschema-gentypesuv
uv add jsonschema-gentypespoetry
poetry add jsonschema-gentypesInstalling jsonschema-gentypes
Before you install
Low friction: pure Python wheel with six common runtime dependencies (PyYAML, jsonschema, referencing, requests, typing-extensions, urllib3). Actively maintained with recent release and no known vulnerabilities.
License in practice
BSD-2-Clause is permissive; you can use this in commercial and proprietary projects with minimal restrictions beyond retaining the license notice.
Quickstart
pip install jsonschema-gentypes
jsonschema-gentypes --json-schema=schema.json --python=types.py
# Or via config file (jsonschema-gentypes.yaml):
jsonschema-gentypes
Requires Python 3.10 or later (supports 3.10, 3.11, 3.12, 3.13).
Verify before relying
- Whether generated types are fully compatible with runtime type checkers like mypy and pyright in all schema patterns.
- Performance characteristics when processing very large or deeply nested JSON schemas.
- Completeness of OpenAPI3 support relative to the full OpenAPI3 specification.
Package facts
| License | BSD-2-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — PyYAML, jsonschema, referencing, requests, typing-extensions, urllib3 |
| Maintenance | actively maintained — 261 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 75,436/month — #14,714 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: jsonschema_gentypes-2.13.0-py3-none-any.whl
Keywords: jsonschema, types
Tags
More Code Generators packages
Proto Plus wraps protocol buffers to provide…
permissive · top 1,000 on PyPI
CythonCython is a source code translator that…
permissive · top 1,000 on PyPI
asttokensAnnotates Python abstract syntax trees with the…
permissive · top 1,000 on PyPI
beartypeBeartype is a runtime type checker that…
permissive · top 1,000 on PyPI
llvmlitellvmlite provides a lightweight Python binding…
permissive · top 1,000 on PyPI
astorastor converts Python abstract syntax trees…
permissive · top 5,000 on PyPI
check-jsonschemaA command-line tool and pre-commit hook that…
permissive · top 5,000 on PyPI
datamodel-code-generatorGenerates Python data models (Pydantic,…
permissive · top 5,000 on PyPI
marshmallow-jsonschemaConverts marshmallow schemas into JSON Schema…
permissive · top 5,000 on PyPI
jsonschema-pydanticConverts JSON Schema definitions into Pydantic…
unclear · top 15,000 on PyPI
jschema-to-pythonGenerates Python class definitions from JSON…
permissive · top 5,000 on PyPI
jsonschema-typed-v2Generates Python TypedDict type annotations…
permissive · top 15,000 on PyPI
dydanticDynamically generates Pydantic models from JSON…
permissive · top 5,000 on PyPI
openapi-schema-pydanticProvides Pydantic classes that map to the…
permissive · top 5,000 on PyPI
json-ref-dictProvides a dict-like interface to JSONSchema…
permissive · top 15,000 on PyPI
shrub.pyProgrammatically generate Evergreen project…
permissive · top 5,000 on PyPI