json_annotation
Classes and helper functions that support JSON code generation via the `json_serializable` package.
4.12.0
12M downloads/mo
#8 most downloaded on pub.dev
google/json_serializable.dart
What this package is like to depend on
Last release 3 months ago
15 May 2026
Release timing varies
gaps range from 3 weeks to 1.8 years
Nearly every release is documented
notes for 39 of 39 stable releases
Nothing withdrawn
no release was ever pulled
9 years old
41 releases · first in 2017
3 releases in the last 12 months
see the full history below
Release timeline
41 releases · Sep 2017 to May 2026Releases
latest 41-
4.12.015 May 2026Release notes
Open source →- Add
JsonKey.explicitJsonNullWhenNonNullFieldfor PATCH-style tri-state JSON
fields (omit key vs explicitnullvs value).
Release notes
Open source →- Add
JsonKey.explicitJsonNullWhenNonNullFieldfor PATCH-style tri-state JSON fields (omit key vs explicitnullvs value).
- Add
-
4.11.019 Feb 2026 -
4.10.029 Jan 2026Release notes
Open source →- Support
JsonKeyannotation on constructor parameters. - Add
JsonSerializable(createJsonSchema: true). - Require
meta: ^1.16.0 - Require
sdk: ^3.9.0
Release notes
Open source →- Support
JsonKeyannotation on constructor parameters. - Add
JsonSerializable(createJsonSchema: true). (Huge thanks to Chris Sells for the PR!) - Require
meta: ^1.16.0 - Require
sdk: ^3.9.0
- Support
-
4.9.024 Apr 2024 -
4.8.103 May 2023 -
4.8.019 Jan 2023Release notes
Open source →- DEPRECATED
JsonKey.ignore. Replaced by... - Added
JsonKey.includeFromJsonandJsonKey.includeToJsonto allow fine-grained control of if a field is encoded/decoded. - Added
JsonSerializable.createPerFieldToJsonwhich allows generating a_$ModelPerFieldToJson, enabling partial encoding of a model. - Update
JsonKeydocumentation to align with new features inpackage:json_serializable. - Require Dart SDK
>=2.18.0.
- DEPRECATED
-
4.7.021 Sep 2022Release notes
Open source →- Added
JsonEnum.valueFieldwhich allows specifying a field in an "enhanced enum" to use for serialization instead of specifying each value individually withJsonValue. - Require Dart SDK 2.17
- Added
-
4.6.007 Jul 2022 -
4.5.027 Apr 2022 -
4.4.001 Dec 2021Release notes
Open source →- Added
JsonKey.readValue. - Non-breaking updates to
checkedCreateandcheckedConvertto supportJsonKey.readValue. - Improved
toStringin included exceptions.
- Added
-
4.4.0-beta.001 Dec 2021 pre-releaseNothing published for this version
-
4.3.014 Oct 2021Release notes
Open source →- Changed the type of
JsonKey.unknownEnumValuefromObject?toEnum?. Assuming this feature has been used correctly, it shouldn't be a breaking change. - Changed the type of the
$enumDecodeNullableparameterunknownValuefromObject?toEnum?.
- Changed the type of
-
4.2.013 Oct 2021Release notes
Open source →- Added
JsonSerializable.constructorfield to allow specifying an alternative constructor to invoke when creating afromJsonhelper. - Added
JsonEnumfor annotatingenumtypes. - Added
$enumDecodeNullableand$enumDecodehelpers to minimize generated code. - Added
constJsonKey.nullForUndefinedEnumValuefor use inJsonKey.unknownEnumValuewhen you want to usenullfor an unknown value. - Require Dart SDK
>=2.14.0.
- Added
-
4.1.013 Jul 2021Release notes
Open source →- Added a
constconstructor toJsonConverter. - Added
$checkedCreatehelper that will be used bypackage:json_serializablev5+ and replaces both$checkedNewand$checkedConvert. - Annotate annotations with the supported target types, to minimize incorrect usage.
- Added a
-
4.0.119 Mar 2021Release notes
Open source →- Fix a potential error with
checked: truewhenArgumentError.messageisnull. - Updated
JsonSerializable.fromJsonto handlenullvalues. - Deprecate
JsonSerializabledefaultsandwithDefaults().
- Fix a potential error with
-
4.0.011 Feb 2021Release notes
Open source →- Support null safety.
- Requires Dart 2.12.
- Updated
$checkedConverthelper to support null-safety. - Removed the
nullablefield onJsonKey– the constructor entry still exists, but it's marked@Deprecated. The nullability of a field is now determined by the Dart type system.
-
4.0.0-nullsafety.003 Dec 2020 pre-releaseNothing published for this version
-
3.1.120 Nov 2020Release notes
Open source →- Avoid
nullvalues forCheckedFromJsonException.messageby usingtoString()with unrecognized error types. - Added a helpful
UnrecognizedKeysException.toString(). - Fixed doc comments for
JsonSerializable.genericArgumentFactories.
- Avoid
-
3.1.022 Sep 2020Release notes
Open source →- Added
JsonSerializable.genericArgumentFactoriesfield. - Require at least Dart
2.7.0.
- Added
-
3.0.123 Dec 2019 -
3.0.007 Aug 2019Release notes
Open source →- BREAKING Removed
JsonSerializable.useWrappersand associated$-prefixed helpers. - BREAKING Removed
JsonSerializable.generateToJsonFunction. - BREAKING Removed
encodeEmptyCollectionfromJsonSerializableandJsonKey. - Added
JsonSerializable.ignoreUnannotated. - Added
JsonKey.unknownEnumValue. - Require at least Dart
2.3.0.
- BREAKING Removed
-
2.4.016 May 2019Release notes
Open source →- Deprecate members that will be removed in
json_annotation3.0.0and that are not supported injson_serializable3.0.0.JsonSerializable.useWrappersand associated$-prefixed helpersJsonSerializable.generateToJsonFunction,encodeEmptyCollectionfromJsonSerializableandJsonKey.
- Deprecate members that will be removed in
-
2.3.009 May 2019Release notes
Open source →- Added
pascalas an additionalfieldRenameoption. - Require at least Dart
2.2.0.
- Added
-
2.2.009 Apr 2019Release notes
Open source →- Add an optional (named)
badKeyparameter and field toCheckedFromJsonException.
- Add an optional (named)
-
2.1.001 Apr 2019Release notes
Open source →-
Require at least Dart
2.1.1. -
Added to
encodeEmptyCollectiontoJsonKeyandJsonSerializable. -
JsonSerializable.fromJsonnow throwsCheckedFromJsonExceptionon errors. This is potentially a breaking change. -
Added a more helpful
toStringtoCheckedFromJsonException.
-
-
2.0.023 Oct 2018Release notes
Open source →-
Potentially Breaking
JsonSerializableno longer sets default values for fields when constructor arguments are unset ornull. This is not likely an issue for developers using this class as an annotation with a compatible version ofpackage:json_serializable, but it may cause issues if class is used in other contexts. -
Support all
build.yamlconfiguration options on classes by adding a number of fields toJsonSerializable:anyMap,checked,explicitToJson,generateToJsonFunction, anduseWrappers.
-
-
1.2.018 Sep 2018 -
1.1.009 Aug 2018Release notes
Open source →- Added the
fieldRenameoption toJsonSerializableand the associatedFieldRenameenum.
- Added the
-
1.0.024 Jul 2018Release notes
Open source →-
Added
JsonValueclass for annotatingenumfields with a custom serialization value. -
Removed
$checkAllowedKeys,$enumDecodeand$enumDecodeNullablewhich are no longer needed by the latest release ofpackage:json_serializable.
-
-
0.2.921 Jun 2018Release notes
Open source →- When
FormatExceptionis caught in "checked mode", use themessageproperty when creatingCheckedFromJsonException.
- When
-
0.2.9+120 Jul 2018 -
0.2.808 Jun 2018Release notes
Open source →-
Added
$checkKeyshelper function and deprecated$checkAllowedKeys. Upgrading to the latestjson_serializableand re-running your build will eliminate any@deprecatedhints you see. -
Added
BadKeyExceptionexception which is the abstract super class forMissingRequiredKeysException,UnrecognizedKeysException, andDisallowedNullValueException. -
Added
JsonKey.requiredfield and an associatedMissingRequiredKeysExceptionthat is thrown whenrequiredfields don't have corresponding keys in a source JSON map. -
Added
JsonKey.disallowNullValuefield and an associatedDisallowedNullValueExceptionthat is thrown when corresponding keys exist in a source JSON map, but their values arenull. -
Updated documentation of
JsonSerializable.createToJsonto include details of the newgenerate_to_json_functionconfiguration option.
-
-
0.2.701 Jun 2018Release notes
Open source →- Added
JsonSerializable.disallowUnrecognizedKeys.- Added a helper function to support this option. This function starts with a
$and should only be referenced by generated code. It is not meant for direct use. - Added
UnrecognizedKeysExceptionfor reporting errors.
- Added a helper function to support this option. This function starts with a
- Added
-
0.2.7+104 Jun 2018Release notes
Open source →- Small improvement to
UnrecognizedKeysException.messageoutput and documentation comments.
- Small improvement to
-
0.2.630 May 2018Release notes
Open source →-
CheckedFromJsonException- Added a public constructor to support hand-written JSON decoding logic.
- The
messageproperty is nowString(instead ofObject).
-
Added
JsonKey.defaultValue. -
Added helpers for deserialization of
enumvalues. These functions starting with$are referenced by generated code. They are not meant for direct use.
-
-
0.2.522 May 2018Release notes
Open source →-
Added
CheckedFromJsonExceptionwhich is thrown by code generated whencheckedis enabled injson_serializable. -
Added functions to support the
checkedgeneration option. These functions starting with$are referenced by generated code. They are not meant for direct use.
-
-
0.2.410 May 2018 -
0.2.303 Apr 2018 -
0.2.215 Dec 2017Release notes
Open source →- Added a helper class –
$JsonMapWrapper– and helper functions –$wrapMap,$wrapMapHandleNull,$wrapList, and$wrapListHandleNull– to support theuseWrappersoption added toJsonSerializableGeneratorinv0.3.0ofpackage:json_serializable.
- Added a helper class –
-
0.2.102 Nov 2017Release notes
Open source →JsonSerializableclass annotation- Added
nullablefield. - Fixed doc comment.
- Added
-
0.2.027 Sep 2017