finds.dev← search

// the find

datamodel-code-generator/datamodel-code-generator

★ 4,027 · Python · MIT · updated Oct 2026

Generate Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JSON/YAML/CSV.

A schema-to-Python-model generator: feed it OpenAPI, AsyncAPI, JSON Schema, Avro, Protobuf, XML Schema, GraphQL, MCP tool schemas, or raw JSON/YAML/CSV, and it emits Pydantic v2, dataclasses, TypedDict, or msgspec.Struct code. Good fit for teams that maintain typed Python models against an external API or an internal schema and don't want to hand-write or hand-sync them.

The input matrix is genuinely wider than any competing tool - it also retargets existing Pydantic/dataclass/TypedDict classes between output styles via --input-model, which is a real escape hatch when you're migrating pydantic v1 to v2. It's load-bearing in CI pipelines for openai/codex, modelcontextprotocol/python-sdk, apache/airflow, PostHog, and airbyte, so its correctness has been stress-tested against real-world schemas, not just toy fixtures. CI also runs conformance passes against pinned external corpora (JSON Schema test suite, XML Schema, Avro, Protobuf, AsyncAPI specs) which is a stronger correctness signal than most codegen tools bother with. Explicit --target-python-version and --target-pydantic-version flags mean you can pin generated syntax independently of what's installed, useful when generating code for a different environment than the one running the generator.

The project has quietly grown well past 'generate data models' - the source tree has a _client and _fastapi tree generating full HTTP clients and FastAPI servers, with OAuth, retry, rotation, pagination, and multipart handling baked into generated runtime code. That's a lot of generated machinery to audit and trust if you just wanted a Pet model from a JSON Schema. The formatter story is mid-migration: three separate formatter stacks (builtin, black/isort, ruff) to pick between, with black/isort still the default despite being the slowest option and the thing the builtin formatter is explicitly trying to replace. Remote $ref resolution and several input formats (GraphQL, Protobuf, HTTP) require separate pip extras, so a schema that pulls in a feature you didn't anticipate means a mid-project dependency scramble. There's a dedicated list-deprecations CLI command and docs page, which signals the flag surface churns release to release - scripts and CI configs pinned to specific options will need periodic babysitting across upgrades.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →