A lightweight library that seamlessly combines Pydantic models, JSON Schema, and IPyWidgets to generate interactive, schema‐driven forms in Jupyter notebooks. Define your data models with Pydantic (or raw JSON Schema), and this package will produce Jupyter widgets for editing and validating.
- Automatic Widget Generation: Convert any JSON Schema or Pydantic model into a fully interactive IPyWidgets form.
- Pydantic Integration: Leverage Pydantic’s data validation, typing, and JSON Schema generation.
- Nested Structures: Support for nested objects, arrays, dictionaries, enums, unions, and optional fields.
- Inline Editing UI: The
PydanticEditorMixinwraps Pydantic models with an “Edit → Save/Cancel” toolbar for in‐place modifications.
ipywidgets-jsonschema can be installed with pip:
python -m pip install ipywidgets-jsonschema
Alternatively, you can get it from conda-forge:
conda install -c conda-forge ipywidgets-jsonschema
from pydantic import BaseModel, Field
from ipywidgets_jsonschema import Form
class Person(BaseModel):
name: str = Field(..., description="Your full name")
age: int = Field(..., ge=0, description="Your age in years")
email: str = Field(None, description="Optional email")
form = Form(Person)
form.show()
# Interact with the form in Jupyter; retrieve validated data:
print(form.data) # e.g. {"name": "Alice", "age": 30, "email": "alice@example.com"}
That’s it—your Pydantic model is now an interactive form. For more advanced examples (nested models, enums, unions, customization), see the Documentation.
Released under the MIT License.