This can be specified using ConverterType to use
the custom converter for all values of the attributed type, or using ConverterType
to use the custom converter for a single property. The latter approach can also be used to
allow for conversion of types you don't control (e.g. to serialize Guid properties
as strings).
This interface is never passed a null value and should never return a null value. Null values are transparently
handled by the serialization framework; if a document contains a null value, that will always be deserialized
to a null reference (or null value of a nullable value type).
Converters express their conversions in terms of regular .NET types: strings, integers, lists, dictionaries and so
on. The result of serializing an object of type T is then processed by the default serialization
handling into the Firestore protocol buffer representation. Deserialization works the same way: first the Firestore
protocol buffer representation is converted into .NET types in the default manner for this library, and the result is
passed to the converter. Note that this means there can be asymmetry between serialization and deserialization: if the
ToFirestore(T) method returns an int, deserializing the result will involve
the FromFirestore(object) method receiving an long value as that's the default
.NET representation of a Firestore integer.
Converters that intend to convert objects into top-level documents should return a string-keyed dictionary of values
from ToFirestore(T). On deserialization, FromFirestore(object) will be passed a value
implementing IDictionary<TKey, TValue> with a key type of string and a value type
of object.
Methods
FromFirestore(object)
T FromFirestore(object value)
Converts a value from its Firestore representation.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eIFirestoreConverter<T>\u003c/code\u003e interface facilitates custom serialization and deserialization within the Firestore API, enabling the conversion of .NET types to and from their Firestore representations.\u003c/p\u003e\n"],["\u003cp\u003eThis interface can be utilized via \u003ccode\u003eConverterType\u003c/code\u003e to apply custom conversion to all instances of a given type or to specific properties, including types outside the developer's direct control.\u003c/p\u003e\n"],["\u003cp\u003eThe interface handles non-null values exclusively, with null values managed separately by the serialization framework, and it operates with standard .NET types like strings, integers, lists, and dictionaries.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eFromFirestore(object)\u003c/code\u003e method converts a Firestore representation into its corresponding .NET type, while \u003ccode\u003eToFirestore(T)\u003c/code\u003e performs the reverse, transforming a .NET type into its Firestore representation.\u003c/p\u003e\n"],["\u003cp\u003eThe latest documented version for this interface is 3.10.0, with previous versions from 3.9.0 down to 2.3.1 also documented.\u003c/p\u003e\n"]]],[],null,["# Firestore API - Interface IFirestoreConverter<T> (3.10.0)\n\nVersion latestkeyboard_arrow_down\n\n- [3.10.0 (latest)](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.9.0/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.8.0/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.7.0/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.6.0/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [3.5.1](/dotnet/docs/reference/Google.Cloud.Firestore/3.5.1/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [3.4.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.4.0/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [3.3.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.3.0/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [3.2.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.2.0/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [3.1.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.1.0/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [3.0.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.0.0/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.Firestore/2.5.0/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.Firestore/2.4.0/Google.Cloud.Firestore.IFirestoreConverter-1)\n- [2.3.1](/dotnet/docs/reference/Google.Cloud.Firestore/2.3.1/Google.Cloud.Firestore.IFirestoreConverter-1) \n\n public interface IFirestoreConverter\u003cT\u003e\n\nReference documentation and code samples for the Firestore API interface IFirestoreConverter\n\n\u003cbr /\u003e\n\nCustom converter used during serialization and deserialization.\n\nNamespace\n---------\n\n[Google.Cloud.Firestore](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore)\n\nAssembly\n--------\n\nGoogle.Cloud.Firestore.dll\n\nRemarks\n-------\n\n\nThis can be specified using [ConverterType](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.FirestoreDataAttribute#Google_Cloud_Firestore_FirestoreDataAttribute_ConverterType) to use\nthe custom converter for all values of the attributed type, or using [ConverterType](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.FirestorePropertyAttribute#Google_Cloud_Firestore_FirestorePropertyAttribute_ConverterType)\nto use the custom converter for a single property. The latter approach can also be used to\nallow for conversion of types you don't control (e.g. to serialize [Guid](https://learn.microsoft.com/dotnet/api/system.guid) properties\nas strings).\n\n\nThis interface is never passed a null value and should never return a null value. Null values are transparently\nhandled by the serialization framework; if a document contains a null value, that will always be deserialized\nto a null reference (or null value of a nullable value type).\n\n\nConverters express their conversions in terms of regular .NET types: strings, integers, lists, dictionaries and so\non. The result of serializing an object of type `T` is then processed by the default serialization\nhandling into the Firestore protocol buffer representation. Deserialization works the same way: first the Firestore\nprotocol buffer representation is converted into .NET types in the default manner for this library, and the result is\npassed to the converter. Note that this means there can be asymmetry between serialization and deserialization: if the\n[ToFirestore(T)](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.IFirestoreConverter-1#Google_Cloud_Firestore_IFirestoreConverter_1_ToFirestore__0_) method returns an [int](https://learn.microsoft.com/dotnet/api/system.int32), deserializing the result will involve\nthe [FromFirestore(object)](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.IFirestoreConverter-1#Google_Cloud_Firestore_IFirestoreConverter_1_FromFirestore_System_Object_) method receiving an [long](https://learn.microsoft.com/dotnet/api/system.int64) value as that's the default\n.NET representation of a Firestore integer.\n\n\nConverters that intend to convert objects into top-level documents should return a string-keyed dictionary of values\nfrom [ToFirestore(T)](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.IFirestoreConverter-1#Google_Cloud_Firestore_IFirestoreConverter_1_ToFirestore__0_). On deserialization, [FromFirestore(object)](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.IFirestoreConverter-1#Google_Cloud_Firestore_IFirestoreConverter_1_FromFirestore_System_Object_) will be passed a value\nimplementing [IDictionary\\\u003cTKey, TValue\\\u003e](https://learn.microsoft.com/dotnet/api/system.collections.generic.idictionary-2) with a key type of [string](https://learn.microsoft.com/dotnet/api/system.string) and a value type\nof [object](https://learn.microsoft.com/dotnet/api/system.object).\n\nMethods\n-------\n\n### FromFirestore(object)\n\n T FromFirestore(object value)\n\nConverts a value from its Firestore representation.\n\n### ToFirestore(T)\n\n object ToFirestore(T value)\n\nConverts a value to its Firestore representation."]]