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.3

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.3
File Size Uploaded Provenance Actions
json_schema_parser-1.0.3.tar.gz 7.3 kB Without provenance Details for json_schema_parser-1.0.3.tar.gz

Built distribution (wheel)

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

Total release size: 15.0 kB

Release files / json_schema_parser-1.0.3.tar.gz

Download URL json_schema_parser-1.0.3.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
81274ca207295f6ae7c872d7a8835b527d3b727a63e4521bdb32dde8462da9f8
BLAKE2b-256 checksum
How to use checksums
6dfafe0bfe70c49f68969d4d43620f9b24592beaeda3c50c33992d4d96020114
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.3-py3-none-any.whl

Download URL json_schema_parser-1.0.3-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb37d94418aefaeba3cabba97994477bfaa65b5031b6e7cba40fdd94a258a16f
BLAKE2b-256 checksum
How to use checksums
41eb90ea076b5c77b6766d1eed9d442d950e114f7dc2aec1b809e8279c9e1a21
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.3

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