Convert JSON to Pydantic v2 BaseModel classes for Python and FastAPI.
Free online JSON to Pydantic model generator. Paste any JSON object or array and get Python Pydantic BaseModel classes with proper type annotations, Optional[T] for nullable fields, List[T] for arrays, datetime for date strings, and Field aliases for non-snake_case keys. Supports both Pydantic v1 and v2. Perfect for FastAPI, Django, and Python developers. Runs entirely in your browser.
Keywords: json to pydantic, json to pydantic model, pydantic generator, python model from json, fastapi pydantic model, pydantic basemodel generator, json to python class, pydantic v2 model, python json types, fastapi request model, pydantic schema generator
Tags: json, python, pydantic, fastapi, model, converter, generator
Paste valid JSON into the input area on the left.
Set the root model name (defaults to 'Root') using the option field.
Choose the Pydantic version: v1 or v2.
Toggle field aliases to generate Field(alias=...) for JSON keys that differ from Python naming conventions.
Click Convert or press ⌘↵ (Mac) / Ctrl+Enter (Windows) to generate Pydantic models.
Copy the generated Python code or download it as a .py file.
Generates Pydantic v1 and v2 BaseModel classes from any JSON object or array.
Supports nested objects — creates separate named models for each nested structure.
Smart type inference: str, int, float, bool, None, List[T], Optional[T], and nested model types.
Optional Field(alias=...) for snake_case Python names that map to camelCase JSON keys.
Pydantic v2 mode uses model_config = ConfigDict(populate_by_name=True) for alias support.
Correct Optional[T] for nullable fields.
Works entirely in your browser — JSON never leaves your device.
Keyboard shortcut ⌘↵ for instant conversion.