A high-performance deep cloning library for .NET that combines source generation with reflection fallback for zero-config object copying.
FastCloner is a deep cloning library for .NET that creates independent copies of complex object graphs. It solves the problem of efficiently and correctly duplicating objects with nested references, circular dependencies, and polymorphic types, which is challenging with manual copying or serialization-based approaches.
.NET developers who need to perform deep cloning of objects in performance-critical applications, such as caching systems, state management, or data transformation pipelines.
Developers choose FastCloner for its benchmark-proven speed, correctness in edge cases, and hybrid approach that combines the performance of source generation with the flexibility of reflection, all without external dependencies.
The fastest deep cloning library for .NET – zero-config, works out of the box.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmarked as the fastest .NET deep cloning library, with up to 300x speed-up over Newtonsoft.Json and 160x over System.Text.Json, as shown in independent third-party tests.
Correctly manages complex scenarios like polymorphism, circular references, readonly members, and collections, backed by over 800 tests ensuring reliability.
Combines source generation for compile-time speed with reflection fallback for safety, allowing deep cloning to work out of the box from .NET 4.6 to .NET 10+.
Relies only on the standard .NET library, making it easy to embed or integrate without external package bloat, as noted in the README.
Offers fine-grained customization via attributes like Clone, Reference, or Ignore, and runtime settings for per-type or per-member cloning behavior.
Cloning unmanaged resources such as IntPtr can lead to side-effects, as the library lacks metadata for buffer lengths, a limitation explicitly mentioned in the README.
Requires installing and configuring the FastCloner.SourceGenerator package, adding complexity to build processes and potentially slowing IDE performance during incremental updates.
Advanced features like identity preservation, nullability trust, or custom contexts involve attribute annotations and runtime APIs that can be overwhelming for simple use cases.