NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #1056 most downloaded on PyPI
Datamodel Code Generator
Last release today
16 Sep 2026
Ships fairly regularly
a new release about every 9 days
Nearly every release is documented
notes for 60 of the last 60 stable releases
1 version withdrawn
withdrawn after publishing
7 years old
286 releases · first in 2019
Fix extra blank line after custom file header with future imports by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2638
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.42.2...0.43.0
One column per quarter.
Fix Python 3.9 compatibility regression in _scc.py by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2628
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.42.1...0.42.2
Add named profile support and --ignore-pyproject option for pyproject.toml configuration by @koxudaxi in https://github.com/koxudaxi/datamodel-code-ge
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.42.0...0.42.1
Improve type resolution for inherited fields in allOf with complex schemas by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2
If you use custom Jinja2 templates, you may need to update them to handle default_factory correctly with --use-annotated.
A new property field.has_default_factory_in_field has been added. Templates should check this property to avoid generating duplicate
default assignments when Field(default_factory=...) is used.
Example change in templates:
{# Before #}
{%- if not (field.required or ...) %} = {{ field.represented_default }}{% endif %}
{# After #}
{%- if not field.has_default_factory_in_field and not (field.required or ...) %} = {{ field.represented_default }}{% endif %}
Affected built-in templates:
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.41.0...0.42.0
Fix: resolve relative $ref correctly when fetching schemas from HTTP URLs by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/26
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.40.0...0.41.0
Fix invalid Union syntax when using --collapse-root-models by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2594
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.39.0...0.40.0
Add --all-exports-scope and --all-exports-collision-strategy options for recursive exports by @koxudaxi in https://github.com/koxudaxi/datamodel-code-
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.38.0...0.39.0
Fix transitive local reference resolution in external schema files by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2577
__all__ in __init__.py by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2586Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.37.0...0.38.0
Add PEP 257 docstrings to modules and test files by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2548
--generate-pyproject-config CLI option by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2551webhooks in --openapi-scopes by @HNygard in https://github.com/koxudaxi/datamodel-code-generator/pull/2481Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.36.0...0.37.0
OpenAPI byte-formatted string properties for Pydantic v2 are now generated as bytes fields that Pydantic automatically decodes from base64-encoded str
OpenAPI byte-formatted string properties for Pydantic v2 are now generated as bytes fields that Pydantic automatically decodes from base64-encoded strings at runtime. Code that relied on these fields being plain str values (the encoded representation) may need to be updated. by @ilovelinux in https://github.com/koxudaxi/datamodel-code-generator/pull/2511 (closes https://github.com/koxudaxi/datamodel-code-generator/issues/189)
Enums inferred from OpenAPI / JSON Schema string or integer enums are now generated as specialized StrEnum / IntEnum subclasses by default when supported by the target Python version. This changes the base class of existing generated enums and can affect comparisons, JSON encoding, and downstream type checks. You can opt out using the --no-use-specialized-enum CLI flag or use_specialized_enum = false in the configuration file. by @ilovelinux in https://github.com/koxudaxi/datamodel-code-generator/pull/2512 (closes https://github.com/koxudaxi/datamodel-code-generator/issues/1313 and https://github.com/koxudaxi/datamodel-code-generator/issues/2534)
For some Pydantic v2 collection schemas that previously generated a RootModel wrapper (for example the MyArray case described in https://github.com/koxudaxi/datamodel-code-generator/issues/1830), the generated code now uses a TypeAlias instead of a dedicated model class. Projects that import or subclass such wrapper models may need to adjust to use the alias instead. by @butvinm in https://github.com/koxudaxi/datamodel-code-generator/pull/2505 (closes https://github.com/koxudaxi/datamodel-code-generator/issues/1848, https://github.com/koxudaxi/datamodel-code-generator/issues/2018, https://github.com/koxudaxi/datamodel-code-generator/issues/2427, and https://github.com/koxudaxi/datamodel-code-generator/issues/2487)
byte in Pydantic v2 by @ilovelinux in https://github.com/koxudaxi/datamodel-code-generator/pull/2511TYPE_CHECKING blocks by @ilovelinux in https://github.com/koxudaxi/datamodel-code-generator/pull/2539null type by @ilovelinux in https://github.com/koxudaxi/datamodel-code-generator/pull/2542Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.35.0...0.36.0
Add support to Python 3.14 by @ilovelinux in https://github.com/koxudaxi/datamodel-code-generator/pull/2469
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.34.0...0.35.0
TypedDict: Add support for const fields using Literal by @erandagan in https://github.com/koxudaxi/datamodel-code-generator/pull/2475
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.33.0...0.34.0
Run the test suite daily to check breaking changes by @gaborbernat in https://github.com/koxudaxi/datamodel-code-generator/pull/2479
tmp_path fixture instead of TemporaryDirectory by @ilovelinux in https://github.com/koxudaxi/datamodel-code-generator/pull/2463@model_validator() usage for Pydantic 2.12 by @ilovelinux in https://github.com/koxudaxi/datamodel-code-generator/pull/2472Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.32.0...0.33.0
modify __typename field to honor --use-default-kwarg flag by @rpmcginty in https://github.com/koxudaxi/datamodel-code-generator/pull/2420
--use-default-kwarg flag by @rpmcginty in https://github.com/koxudaxi/datamodel-code-generator/pull/2420Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.31.2...0.32.0
fix: prevent code injection through filename in generated headers by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2428
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.31.1...0.31.2
fix: documentation for --allow-extra-fields by @cosmo-grant in https://github.com/koxudaxi/datamodel-code-generator/pull/2416
--extra-fields option in pydantic v2 models by @cosmo-grant in https://github.com/koxudaxi/datamodel-code-generator/pull/2423Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.31.0...0.31.1
Resolve capitalize-enum-member not working with use-subclass-enum and snake-case-field when typed enum by @kevin-paulson-mindbridge-ai in https://gith
--extra-fields option to allow, forbid, or ignore extra fields by @cosmo-grant in https://github.com/koxudaxi/datamodel-code-generator/pull/2417Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.30.2...0.31.0
[pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in https://github.com/koxudaxi/datamodel-code-generator/pull/2393
coerce_numbers_to_str in ConfigDict by @robotadam in https://github.com/koxudaxi/datamodel-code-generator/pull/2394--frozen-dataclasses flag to generate frozen dataclasses by @K-dash in https://github.com/koxudaxi/datamodel-code-generator/pull/2408Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.30.1...0.30.2
fix: TypeError: '<' not supported between instances of 'str' and 'NoneType' by @gjcarneiro in https://github.com/koxudaxi/datamodel-code-generator/pul
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.30.0...0.30.1
feat: add new option --parent-scoped-naming to avoid name collisions by @gjcarneiro in https://github.com/koxudaxi/datamodel-code-generator/pull/2373
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.29.0...0.30.0
Fix shadowed import errors by aliasing conflicting symbols in generated models by @sternakt in https://github.com/koxudaxi/datamodel-code-generator/pu
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.28.5...0.29.0
fix: Fix Union type parsing with recursive None removal by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2342
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.28.4...0.28.5
feat: add ruff formatters by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2340
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.28.3...0.28.4
[pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in https://github.com/koxudaxi/datamodel-code-generator/pull/2331
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.28.2...0.28.3
[pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in https://github.com/koxudaxi/datamodel-code-generator/pull/2328
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.28.1...0.28.2
Graphql --set-default-enum-member by @andrew-womeldorf in https://github.com/koxudaxi/datamodel-code-generator/pull/2323
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.28.0...0.28.1
Drop <3.9 support as run and generation target by @gaborbernat in https://github.com/koxudaxi/datamodel-code-generator/pull/2324
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.27.3...0.28.0
Reuse extras instead of dependency groups by @gaborbernat in https://github.com/koxudaxi/datamodel-code-generator/pull/2307
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.27.2...0.27.3
fix: Fix extra dependencies by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2306
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.27.1...0.27.2
Support isort 6 by @cjwatson in https://github.com/koxudaxi/datamodel-code-generator/pull/2289
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.27.0...0.27.1
Migrate to use uv instead of poetry by @gaborbernat in https://github.com/koxudaxi/datamodel-code-generator/pull/2288
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.26.5...0.27.0
typo: Fix 'Allow to' sentence. by @jas4711 in https://github.com/koxudaxi/datamodel-code-generator/pull/2240
[tool.black] section is omitted by @otonnesen in https://github.com/koxudaxi/datamodel-code-generator/pull/2242Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.26.4...0.26.5
remove poetry-lock in .pre-commit-config.yaml by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2184
uri as a supported data type by @joscha in https://github.com/koxudaxi/datamodel-code-generator/pull/2217required with type: [array, null] by @joscha in https://github.com/koxudaxi/datamodel-code-generator/pull/2216Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.26.3...0.26.4
[pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in https://github.com/koxudaxi/datamodel-code-generator/pull/2096
--output-datetime-class datetime by @indrat in https://github.com/koxudaxi/datamodel-code-generator/pull/2124use_enum_values in ConfigDict by @nbro10 in https://github.com/koxudaxi/datamodel-code-generator/pull/2134Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.26.2...0.26.3
New CLI option --output-datetime-class #1996 by @archetipo in https://github.com/koxudaxi/datamodel-code-generator/pull/2100
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.26.1...0.26.2
feat: support string format: duration for pydantic/msgspec by @indrat in https://github.com/koxudaxi/datamodel-code-generator/pull/2084
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.26.0...0.26.1
Drop support python 3.7 on runtime by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/2060
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.25.9...0.26.0
Fix merging config and args by @mahdilamb in https://github.com/koxudaxi/datamodel-code-generator/pull/2015
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.25.8...0.25.9
feat: new cli option --use-exact-imports by @alpoi-x in https://github.com/koxudaxi/datamodel-code-generator/pull/1983
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.25.7...0.25.8
Add from_attributes to ConfigDict by @michael2to3 in https://github.com/koxudaxi/datamodel-code-generator/pull/1946
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.25.6...0.25.7
Fix missing Union by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1905
BaseClassDataType by @rshah-evertz in https://github.com/koxudaxi/datamodel-code-generator/pull/1862Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.25.5...0.25.6
Fix overriden required by @fft001 in https://github.com/koxudaxi/datamodel-code-generator/pull/1868
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.25.4...0.25.5
Fix object instance comparison. Add test. by @jamesbezuk in https://github.com/koxudaxi/datamodel-code-generator/pull/1849
--input-file-type options by @JoeHCQ1 in https://github.com/koxudaxi/datamodel-code-generator/pull/1846Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.25.3...0.25.4
Enable ability to use custom JsonSchemaObject in JsonSchemaParser by @WilliamJamieson in https://github.com/koxudaxi/datamodel-code-generator/pull/178
JsonSchemaObject in JsonSchemaParser by @WilliamJamieson in https://github.com/koxudaxi/datamodel-code-generator/pull/1783Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.25.2...0.25.3
Fix original_name validation by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1755
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.25.1...0.25.2
Fix invalid definition of graphql requirement by @denisart in https://github.com/koxudaxi/datamodel-code-generator/pull/1741
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.25.0...0.25.1
Improve collapse_root_models for list by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1700
Item suffix of anyOf and oneOf model names by https://github.com/koxudaxi/datamodel-code-generator/pull/1682
datetime.datetime to pydantic.AwareDatetime in pydantic v2 by https://github.com/koxudaxi/datamodel-code-generator/pull/1735Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.24.2...0.25.0
Fix join_url bug when httpx 2.4.0 or later by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1699
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.24.1...0.24.2
Add pyyaml by @mmwinther in https://github.com/koxudaxi/datamodel-code-generator/pull/1698
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.24.0...0.24.1
Fix UnionIntFloat json schema generation. by @jboulmier in https://github.com/koxudaxi/datamodel-code-generator/pull/1669
pysnooper, prance, openapi-spec-validator from the default dependencies list.
If you want to use --debug and --validation, please add the extra option when you install packages datamodel-code-generator[debug] and datamodel-code-generator[validation]--validation option will be removed in the new future. please use other tools to validate OpenAPI Schema.Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.23.0...0.24.0
Support $defs for Draft 2019-09 by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1630
--remove-special-field-name-prefix + fields (e.g. enum members) starting with numbers by @lord-haffi in https://github.com/koxudaxi/datamodel-code-generator/pull/1654Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.22.1...0.23.0
Ignore broken pydantic version 2.4.0 by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1593
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.22.0...0.22.1
Organize help options by @howardj99 in https://github.com/koxudaxi/datamodel-code-generator/pull/1540
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.21.5...0.22.0
Added protect namespace to Pydantic v2 ConfigDict by @willarmiros in https://github.com/koxudaxi/datamodel-code-generator/pull/1489
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.21.4...0.21.5
switch away from deprecated pydantic method by @iliakur in https://github.com/koxudaxi/datamodel-code-generator/pull/1485
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.21.3...0.21.4
Give Pydantic V2 its own dump_resolve_reference_action to use model_rebuild not update_forward_refs by @lmmx in https://github.com/koxudaxi/datamodel-
dump_resolve_reference_action to use model_rebuild not update_forward_refs by @lmmx in https://github.com/koxudaxi/datamodel-code-generator/pull/1468base_class validation similar to _validate_base_class to bare generate calls by @kylebebak in https://github.com/koxudaxi/datamodel-code-generator/pull/1453Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.21.2...0.21.3
Pre-commit-hooks by @yehoshuadimarsky in https://github.com/koxudaxi/datamodel-code-generator/pull/1416
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.21.1...0.21.2
Relax version constraint of prance by @tetsuok in https://github.com/koxudaxi/datamodel-code-generator/pull/1409
None by @koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1411Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.21.0...0.21.1
Pydantic v2 is a major release with many breaking changes. See the migration guide for more information: https://docs.pydantic.dev/2.0/migration/
datamodel-code-generator supports Pydantic v1 and v2 as output model type.
Pydantic v2 is a major release with many breaking changes. See the migration guide for more information: https://docs.pydantic.dev/2.0/migration/
__root__ field (a.k.a Custom Root Types)__root__ field (a.k.a Custom Root Types) is removed in pydantic v2.
The model is changed to RootModel
https://docs.pydantic.dev/2.0/migration/#changes-to-pydanticfield
typing.Set. this feature is discussed in https://github.com/pydantic/pydantic-core/issues/296pydantic.Config -> pydantic.ConfigDictFull Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.20.0...0.21.0
Update documentation by @noddycode in https://github.com/koxudaxi/datamodel-code-generator/pull/1316
openapi-spec-validator to 0.5.2 by @Fokko in https://github.com/koxudaxi/datamodel-code-generator/pull/1343Due to differences in file loading order between operating systems, we've added a sorting process when fetching file listings within directories in order to eliminate discrepancies in model and field names. As a result, model names that differ from those generated by existing earlier versions may be produced.
Full Changelog: https://github.com/koxudaxi/datamodel-code-generator/compare/0.19.0...0.20.0
Your coding agent can read these notes before it upgrades. Set up the MCP server →