skillfed

hypothesis-jsonschema

Generate test data from JSON schemata with Hypothesis

hypothesis-jsonschema v0.23.1 3.4M downloads/30d#2,645 on PyPI1
Copyleft license MPL 2.0 AGING released

What it is and what it does

hypothesis-jsonschema bridges Hypothesis (a property-based testing framework) and JSON Schema by converting a schema into a Hypothesis strategy that generates valid JSON data matching that schema. Rather than hand-writing test inputs, you define a schema and the package generates diverse, valid examples automatically—useful for testing APIs, data pipelines, or any code that consumes JSON.

The package exposes a single public function, `from_schema()`, which takes a JSON schema and optional configuration (custom format handlers, encoding constraints) and returns a strategy for Hypothesis's `@given` decorator. It supports JSON Schema drafts 04, 05, and 07, handles non-recursive schema references, and allows you to customize how custom formats are generated. Dependencies are minimal: only hypothesis and jsonschema.

Use it for:

  • Test REST API endpoints by generating valid JSON payloads that match your OpenAPI or JSON Schema specification.
  • Fuzz data validation logic by creating diverse inputs that conform to a schema but exercise edge cases.
  • Verify data transformation pipelines by generating schema-compliant input and checking output correctness.
  • Build schema-driven test suites where test data is derived automatically from your schema rather than hardcoded.
  • Validate custom format handlers by generating data with specific string formats (e.g., email, UUID, card numbers).

Worth the install?

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

Generates random JSON data that conforms to a given JSON schema, for use as test input in property-based testing with Hypothesis.

Yes, if you use Hypothesis for property-based testing and need to generate JSON data. The package is stable, has no known vulnerabilities, and low install friction. The aging maintenance status (no release in 898 days) is a minor concern for new features but not a blocker for current use—the API is small and the underlying dependencies are mature. Suitable for production test suites.

Install

hypothesis-jsonschema on PyPI

pip

pip install hypothesis-jsonschema

uv

uv add hypothesis-jsonschema

poetry

poetry add hypothesis-jsonschema

Installing hypothesis-jsonschema

Before you install

Low friction: pure Python wheel with only two runtime dependencies (hypothesis and jsonschema). Maintenance status is aging—last release was 898 days ago, though the repository remains active with a recent commit on 2025-12-05.

License in practice

Licensed under MPL 2.0 (copyleft). You must disclose source modifications and can use it in proprietary code, but derivative works of the library itself must remain open-source under the same license.

Quickstart

from hypothesis import given
from hypothesis_jsonschema import from_schema

@given(from_schema({"type": "integer", "minimum": 1, "exclusiveMaximum": 10}))
def test_integers(value):
    assert isinstance(value, int)
    assert 1 <= value < 10

Requires Python 3.8 or later. Hypothesis must be installed and configured for your test runner.

Verify before relying

  • Whether the package still actively maintains support for JSON Schema drafts beyond 07, or if newer drafts require manual updates.
  • Current compatibility with the latest versions of hypothesis and jsonschema, given the 898-day gap since last release.

Package facts

License MPL 2.0 (copyleft)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 2 — hypothesis, jsonschema
Maintenance aging — 898 days since the last release
Last repo commit
First released
Downloads 3,380,433/month — #2,645 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: hypothesis_jsonschema-0.23.1-py3-none-any.whl

Keywords: python, testing, fuzzing, property-based-testing, json-schema

Development Status :: 4 - BetaFramework :: HypothesisIntended Audience :: DevelopersLicense :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)Programming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Education :: TestingTopic :: Software Development :: TestingTyping :: Typed

Tags

json schema test data generationhypothesis json schema strategyproperty-based testing jsongenerate json from schemajson schema fuzzinghypothesis test dataschema-driven test generation
property-based-testingjson-schematest-data-generation

More Testing packages

pluggy

Pluggy provides a plugin system that lets you…

permissive · top 100 on PyPI

pytest

pytest is a testing framework that lets you…

permissive · top 100 on PyPI

virtualenv

virtualenv creates isolated Python environments…

permissive · top 100 on PyPI

coverage

Coverage.py measures which lines of Python code…

permissive · top 1,000 on PyPI

pytest-asyncio

pytest-asyncio is a pytest plugin that enables…

permissive · top 1,000 on PyPI

pytest-json-ctrf

A pytest plugin that generates test reports in…

permissive · top 1,000 on PyPI

hypothesis-graphql

Generates arbitrary GraphQL queries matching…

permissive · top 5,000 on PyPI

hypothesis

Hypothesis is a property-based testing library…

copyleft · top 1,000 on PyPI

schemathesis

Schemathesis generates test cases from OpenAPI…

permissive · top 5,000 on PyPI

hegel-core

Hegel-core provides property-based testing data…

permissive · top 15,000 on PyPI

jsonschema-typed-v2

Generates Python TypedDict type annotations…

permissive · top 15,000 on PyPI

marshmallow-jsonschema

Converts marshmallow schemas into JSON Schema…

permissive · top 5,000 on PyPI

dydantic

Dynamically generates Pydantic models from JSON…

permissive · top 5,000 on PyPI

jsonschema-specifications

Provides JSON Schema metaschemas, vocabularies,…

permissive · top 100 on PyPI

jschon

Validates JSON data against JSON Schema (drafts…

permissive · top 15,000 on PyPI

json-ref-dict

Provides a dict-like interface to JSONSchema…

permissive · top 15,000 on PyPI