Jambo is a Python package that automatically converts JSON Schema definitions into Pydantic models. It's designed to streamline schema validation and enforce type safety using Pydantic's powerful validation features.
Created to simplifying the process of dynamically generating Pydantic models for AI frameworks like LangChain, CrewAI, and others.
- ✅ Convert JSON Schema into Pydantic models dynamically
- 🔒 Supports validation for strings, integers, floats, booleans, arrays, and nested objects
- ⚙️ Enforces constraints like
minLength
,maxLength
,pattern
,minimum
,maximum
,uniqueItems
, and more - 📦 Zero config — just pass your schema and get a model
pip install jambo
from jambo.schema_converter import SchemaConverter
schema = {
"title": "Person",
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
},
"required": ["name"],
}
Person = SchemaConverter.build(schema)
obj = Person(name="Alice", age=30)
print(obj)
schema = {
"title": "EmailExample",
"type": "object",
"properties": {
"email": {
"type": "string",
"minLength": 5,
"maxLength": 50,
"pattern": r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$",
},
},
"required": ["email"],
}
Model = SchemaConverter.build(schema)
obj = Model(email="user@example.com")
print(obj)
schema = {
"title": "AgeExample",
"type": "object",
"properties": {
"age": {"type": "integer", "minimum": 0, "maximum": 120}
},
"required": ["age"],
}
Model = SchemaConverter.build(schema)
obj = Model(age=25)
print(obj)
schema = {
"title": "NestedObjectExample",
"type": "object",
"properties": {
"address": {
"type": "object",
"properties": {
"street": {"type": "string"},
"city": {"type": "string"},
},
"required": ["street", "city"],
}
},
"required": ["address"],
}
Model = SchemaConverter.build(schema)
obj = Model(address={"street": "Main St", "city": "Gotham"})
print(obj)
To run the test suite:
poe tests
Or manually:
python -m unittest discover -s tests -v
To set up the project locally:
- Clone the repository
- Install uv (if not already installed)
- Install dependencies:
uv sync
- Set up git hooks:
poe create-hooks
- Support for
enum
andconst
- Support for
anyOf
,allOf
,oneOf
- Schema ref (
$ref
) resolution - Better error reporting for unsupported schema types
PRs are welcome! This project uses MIT for licensing, so feel free to fork and modify as you see fit.
MIT License.