jsonschema

JSON Schema validation library for Python — validates JSON/dict data against JSON Schema drafts (draft-07, draft-2019-09, draft-2020-12). jsonschema features: jsonschema.validate() one-shot validation, jsonschema.Draft202012Validator for explicit draft selection, validator.iter_errors() for all errors not just first, best_match() for human-readable error selection, schema referencing ($ref, $defs), format validators (email, date, uri), custom validators, jsonschema.exceptions.ValidationError with path and schema info, and format checking with jsonschema[format-nongpl] extras. Standard for validating OpenAPI request/response bodies, config files, and agent-generated structured outputs.

Evaluated Mar 06, 2026 (0d ago) v4.x
Homepage ↗ Repo ↗ Developer Tools python jsonschema validation json-schema openapi schema
⚙ Agent Friendliness
68
/ 100
Can an agent use this?
🔒 Security
89
/ 100
Is it safe for agents?
⚡ Reliability
85
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
85
Error Messages
85
Auth Simplicity
98
Rate Limits
98

🔒 Security

TLS Enforcement
90
Auth Strength
90
Scope Granularity
88
Dep. Hygiene
88
Secret Handling
90

Pure validation library — no network calls by default. $ref to remote URLs (http/https) can trigger network requests; disable with custom RefResolver for untrusted schemas. Schema itself is not executable — no code injection risk.

⚡ Reliability

Uptime/SLA
88
Version Stability
85
Breaking Changes
80
Error Recovery
88
AF Security Reliability

Best When

Validating JSON data against JSON Schema specs (OpenAPI schemas, config schemas, agent output schemas) — jsonschema is the reference Python implementation supporting all JSON Schema drafts with detailed error reporting and $ref resolution.

Avoid When

You need type coercion (use pydantic), Python object validation, or high-throughput validation (use fastjsonschema).

Use Cases

  • Agent output validation — schema = {'type': 'object', 'required': ['action', 'params'], 'properties': {'action': {'type': 'string'}, 'params': {'type': 'object'}}}; jsonschema.validate(agent_output, schema) — validate LLM-generated JSON against schema; agent structured output pipeline ensures valid tool calls before execution; ValidationError caught and fed back to LLM for retry
  • Agent API request validation — validator = jsonschema.Draft202012Validator(openapi_schema['components']['schemas']['CreateUser']); errors = list(validator.iter_errors(request_body)) — validate incoming API request body; agent API gateway validates all requests before processing; collect all errors not just first with iter_errors()
  • Agent config file validation — schema = json.load(open('config-schema.json')); jsonschema.validate(yaml.safe_load(open('config.yaml')), schema) — validate YAML/JSON config against schema; agent validates config at startup before any processing; clear error paths show exactly which config field is wrong
  • Agent response schema checking — errors = list(validator.iter_errors(api_response)); best = jsonschema.exceptions.best_match(errors); raise ValueError(f'API response invalid: {best.message}') — validate third-party API response against expected schema; agent detects API contract violations before processing bad data
  • Agent dynamic schema generation — schema = {'type': 'array', 'items': {'type': 'object', 'properties': {k: {'type': 'string'} for k in required_fields}}}; jsonschema.validate(data, schema) — programmatically build schema from field list; agent validates dynamic data structures where schema varies by context

Not For

  • Pydantic-style type coercion — jsonschema validates only, doesn't convert types; '42' doesn't validate as integer; use pydantic for type coercion + validation in one step
  • Python dataclass validation — jsonschema validates dicts/JSON; for Python object validation use pydantic or attrs
  • Performance-critical validation — jsonschema is pure Python and slow for high-throughput validation; use fastjsonschema for 5-10x faster validation in hot paths

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No auth — local validation library.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

jsonschema is MIT licensed. Free for all use.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • jsonschema.validate() raises on first error only — jsonschema.validate(data, schema) raises ValidationError on first problem; agent code collecting all validation errors must use: v = jsonschema.Draft202012Validator(schema); errors = list(v.iter_errors(data)) — collect all errors before reporting back to LLM for one-shot retry
  • Draft version matters for $schema keyword — JSON Schema draft-07 uses 'definitions', draft-2019-09+ uses '$defs'; schema using wrong draft validator raises SchemaError or silently ignores keywords; always use Draft202012Validator unless schema explicitly declares older $schema URI
  • format validation not enforced by default — jsonschema.validate(data, {'type': 'string', 'format': 'email'}) does NOT validate email format by default; format checking requires: jsonschema.validate(data, schema, format_checker=jsonschema.FormatChecker()); agent schema validation for email/date/URI must explicitly enable format checker
  • $ref resolution requires referencing store or registry — schema with $ref to external file fails unless using RefResolver or jsonschema.Registry; agent code loading schemas from multiple files must: resolver = jsonschema.RefResolver('file:///path/', schema); validator = Draft202012Validator(schema, resolver=resolver)
  • error.path is a deque not list — ValidationError.path is collections.deque; agent code accessing error.path[0] works but list(error.path) needed for full path; error.absolute_path gives full path as deque from root; convert with list(error.absolute_path) for readable key path
  • additionalProperties defaults to true — {'type': 'object', 'properties': {'name': {'type': 'string'}}} allows any extra keys; agent schema for strict output validation must add 'additionalProperties': false to reject unexpected fields from LLM; commonly missed causing silent extra field acceptance

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for jsonschema.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-06.

5229
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered