skillfed

jsonschema-typed-v2

Automatic type annotations from JSON schemas

jsonschema-typed-v2 v0.8.0 172.5K downloads/30d#10,337 on PyPI23
Permissive license MIT DORMANT released

What it is and what it does

jsonschema-typed-v2 bridges JSON Schema and Python's type system by converting JSON Schema definitions into TypedDict annotations that mypy can understand. When you annotate a variable with JSONSchema["path/to/schema.json"], the package's mypy plugin intercepts the type and generates a TypedDict matching the schema's structure—translating JSON types (string, number, boolean, array, object) into Python equivalents and marking required vs. optional fields. This lets you catch type errors in JSON-shaped data at static-check time rather than runtime.

The package is a maintained fork of an earlier abandoned project. It depends on jsonschema for schema parsing and mypy for the plugin infrastructure. Most JSON Schema concepts map straightforwardly to Python types, though some (like additionalProperties and self-references) have known limitations. Configuration requires enabling the plugin in mypy.ini and disabling mypy's cache due to how type hints are generated.

Use it for:

  • Validate API request/response payloads against a JSON Schema while getting IDE autocomplete and type errors during development.
  • Ensure configuration files loaded from JSON match an expected schema without writing manual TypedDict classes.
  • Catch typos in JSON object keys and type mismatches in data pipelines before runtime.
  • Generate type stubs for dynamically loaded JSON data in data processing or ETL workflows.
  • Enforce schema compliance in test fixtures and mock data without duplicating type definitions.

Worth the install?

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

Generates Python TypedDict type annotations automatically from JSON Schema definitions, enabling static type checking of JSON data structures through mypy.

Yes, if you actively use JSON Schema and want static type checking without manually writing TypedDict classes. The low install friction and permissive license make adoption easy. However, maintenance is dormant (last release 2020-08-11), and the package depends on mypy's unstable plugin API—newer mypy versions may break it without warning. Suitable for stable projects where you control mypy versions; risky for codebases that auto-upgrade dependencies.

Install

jsonschema-typed-v2 on PyPI

pip

pip install jsonschema-typed-v2

uv

uv add jsonschema-typed-v2

poetry

poetry add jsonschema-typed-v2

Installing jsonschema-typed-v2

Before you install

Low friction—pure Python wheel with only jsonschema and mypy as runtime dependencies. However, maintenance is dormant: last release was 2020-08-11 and last commit 2023-10-03. The package is a maintained fork of an abandoned original, so stability depends on whether the current maintainer continues to support mypy plugin API changes.

License in practice

MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source contexts.

Quickstart

pip install jsonschema-typed-v2

# In mypy.ini:
# [mypy]
# plugins = jsonschema_typed.plugin, jsonschema_typed.optional_typed_dict
# cache_dir = /dev/null

from jsonschema_typed import JSONSchema
data: JSONSchema["path/to/schema.json"] = {"title": "example"}

Requires mypy plugin system integration via mypy.ini configuration and disabling mypy cache. mypy plugin API has no backwards compatibility guarantee, so future mypy versions may break this package.

Verify before relying

  • Whether current mypy versions (post-0.761) are supported; the fact sheet mentions testing only with mypy==0.761.
  • Whether the package works with modern Python 3.11+ or only up to 3.8 as classifiers suggest.
  • Scope of JSON Schema features actually supported beyond the basic types listed (draft-07 compliance level).

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 2 — jsonschema, mypy
Maintenance dormant — 2,194 days since the last release
Last repo commit
First released
Downloads 172,461/month — #10,337 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: jsonschema_typed_v2-0.8.0-py3-none-any.whl

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.7Programming Language :: Python :: 3.8Topic :: Software Development :: Code GeneratorsTopic :: Software Development :: Quality AssuranceTopic :: Software Development :: TestingTyping :: Typed

Tags

json schema to python typesautomatic type annotations from jsontypeddict generator json schemamypy plugin json validationstatic typing for json datajson schema type checkingpython typing from json schema
type-checkingjson-schemamypy-plugin

More Testing packages