Skip to main content

json-schema-parser

A Python library for converting between JSON schema definitions and Pydantic models.

Features

  • Parse a JSON schema dict into a validated Pydantic model
  • Generate a JSON schema dict from any Python type or Pydantic model
  • Supports all common types: integer, float, string, boolean, json, uuid, datetime
  • Supports list (is_many) and optional (is_optional) variants of every type
  • Nested object schemas via ComplexTypeInput

Installation

pip install json-schema-parser

Usage

Parse a JSON schema into a Pydantic model

from json_schema_parser import JsonSchemaParser

schema = {
    "__config": {"field_type": "json", "is_many": False, "is_optional": False, "field_default_value": None, "description": ""},
    "name": {"field_type": "string", "is_many": False, "is_optional": False, "field_default_value": None, "description": "User name"},
    "age":  {"field_type": "integer", "is_many": False, "is_optional": True, "field_default_value": None, "description": "User age"},
}

parser = JsonSchemaParser.model_validate(schema)
Model = parser.generate_pydantic_model("User")

user = Model.model_validate({"name": "Alice", "age": 30})

Generate a JSON schema from a Python type

from json_schema_parser import JsonSchemaParser
from pydantic import BaseModel
from typing import Optional, List

class Address(BaseModel):
    street: str
    city: str

schema = JsonSchemaParser.generate_json_schema_from_data_type(Address)

Supported field types

field_type value Python type
"integer" int
"float" float
"string" str
"boolean" bool
"uuid" UUID
"datetime" datetime
"json" dict / nested model

Set is_many: true to get a List[T], and is_optional: true to get Optional[T].

License

MIT

Metadata

Release files for json-schema-parser 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for json-schema-parser 1.0.4
File Size Uploaded Provenance Actions
json_schema_parser-1.0.4.tar.gz 7.2 kB Without provenance Details for json_schema_parser-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for json-schema-parser 1.0.4
File Interpreter ABI Platform Actions
json_schema_parser-1.0.4-py3-none-any.whl Python 3 none any Details for json_schema_parser-1.0.4-py3-none-any.whl

Total release size: 15.0 kB

Release files / json_schema_parser-1.0.4.tar.gz

Download URL json_schema_parser-1.0.4.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
05ff97785a00db9002d711121ed896eb63dbd36a454e4c0ae1dbc9e8bc0d23fd
BLAKE2b-256 checksum
How to use checksums
ec39b431352868beb59abc6fc57720d6154bb63b2cb905aa4fa737d750549396
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/10.1.0 pkginfo/1.13.3 requests/2.34.2 requests-toolbelt/1.0.0 tqdm/4.70.1 CPython/3.14.8

Release files / json_schema_parser-1.0.4-py3-none-any.whl

Download URL json_schema_parser-1.0.4-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78aba1ddd3d979cb844f1d20f70e1128424fd26d55fd0c797187f65478a6c787
BLAKE2b-256 checksum
How to use checksums
1347002c66c764cc7686a7b48107bba68ac433f1527eff0d34e22b0e93d57128
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/10.1.0 pkginfo/1.13.3 requests/2.34.2 requests-toolbelt/1.0.0 tqdm/4.70.1 CPython/3.14.8

Security for json-schema-parser 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page