# Pydantic V1 to Pydantic V2 Complete Migration Guide
> Framework: Pydantic (v1.10 -> v2.0+)
> Automated Codemod: `pip install bump-pydantic && bump-pydantic .`
> Canonical URL: https://agentnow.in/migrations/pydantic-v1-to-v2-migration

## Summary
Pydantic V2 is rewritten in Rust. BaseSettings moved to pydantic-settings, @validator replaced by @field_validator, and .dict() replaced by .model_dump().

## Key Breaking Changes
- `BaseSettings` moved from `pydantic` to standalone `pydantic-settings` package.
- `@validator` replaced by `@field_validator` with classmethod signature.
- `.dict()` and `.json()` methods replaced by `.model_dump()` and `.model_dump_json()`.
- `parse_obj()` replaced by `.model_validate()`.

## Automated Codemod Command
```bash
pip install bump-pydantic && bump-pydantic .
```

## Verified Code Migration Diff
```diff
// Pydantic V1 -> V2 Migration
- from pydantic import BaseModel, BaseSettings, validator
- class Settings(BaseSettings):
-     email: str
-     @validator('email')
-     def validate_email(cls, v): return v
- data = model.dict()

+ from pydantic import BaseModel, field_validator
+ from pydantic_settings import BaseSettings
+ class Settings(BaseSettings):
+     email: str
+     @field_validator('email', mode='after')
+     @classmethod
+     def validate_email(cls, v: str) -> str: return v
+ data = model.model_dump()
```
