MemoryPack: zero-encoding, extreme-performance C# binary serializer
MemoryPack is a zero-encoding .NET 7/C# 11 binary serializer that benchmarks 2-200x faster than existing C# serialization libraries.
MemoryPack is a new binary serializer built for C# and Unity that leans on a zero-encoding design, copying C# memory directly instead of applying VarInt or tag-based encoding used by most serializers. Benchmarked on .NET 7 with a Ryzen 9 5950X, it outperforms System.Text.Json, protobuf-net, MessagePack for C# and Orleans.Serialization by roughly 10x for standard objects and 2-5x versus other binary serializers, with struct arrays showing gains of 50-200x.
Built by the author of ZeroFormatter, Utf8Json and MessagePack for C#, MemoryPack is a ground-up redesign targeting .NET 7/C# 11's Incremental Source Generator, while still supporting .NET Standard 2.1 (.NET 5/6) and Unity 2021.3 IL2CPP. Because code generation is entirely source-generator based, it avoids dynamic IL emission and reflection, making it Native AOT friendly out of the box.
The library adds modern I/O support (IBufferWriter<byte>, ReadOnlySpan/ReadOnlySequence), deserialization into existing instances, polymorphic (union) serialization, version-tolerant modes, circular reference handling, PipeWriter/Reader streaming, and TypeScript code generation with an ASP.NET Core formatter. For engineers building high-throughput microservices, game networking layers or data-intensive .NET services, MemoryPack offers a compelling low-overhead alternative to existing serializers.