hypothesis-jsonschema
Generate test data from JSON schemata with Hypothesis
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-jsonschemauv
uv add hypothesis-jsonschemapoetry
poetry add hypothesis-jsonschemaInstalling 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
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
hypothesis-graphqlGenerates arbitrary GraphQL queries matching…
permissive · top 5,000 on PyPI
hypothesisHypothesis is a property-based testing library…
copyleft · top 1,000 on PyPI
schemathesisSchemathesis generates test cases from OpenAPI…
permissive · top 5,000 on PyPI
hegel-coreHegel-core provides property-based testing data…
permissive · top 15,000 on PyPI
jsonschema-typed-v2Generates Python TypedDict type annotations…
permissive · top 15,000 on PyPI
marshmallow-jsonschemaConverts marshmallow schemas into JSON Schema…
permissive · top 5,000 on PyPI
dydanticDynamically generates Pydantic models from JSON…
permissive · top 5,000 on PyPI
jsonschema-specificationsProvides JSON Schema metaschemas, vocabularies,…
permissive · top 100 on PyPI
jschonValidates JSON data against JSON Schema (drafts…
permissive · top 15,000 on PyPI
json-ref-dictProvides a dict-like interface to JSONSchema…
permissive · top 15,000 on PyPI