skillfed

jsonschema-gentypes

Tool to generate Python types based on TypedDict from a JSON Schema

jsonschema-gentypes v2.13.0 75.4K downloads/30d#14,714 on PyPI48
Permissive license BSD-2-Clause Active released

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-gentypes

uv

uv add jsonschema-gentypes

poetry

poetry add jsonschema-gentypes

Installing 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

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Software Development :: Code GeneratorsTyping :: Typed

Tags

json schema to python typestypeddict generatorjson schema code generationopenapi3 python typesschema-driven type generationjson schema validation typesautomatic python type stubs
code-generationschema-driventype-safety

More Code Generators packages