Table of Contents

Features

  • Serializes in the compact and fast MessagePack format.
  • No attributes required on your data types. Optional attributes allow customization and improve performance.
  • Supports the latest C# syntax including required and init properties, record classes and structs, and primary constructors.
  • This library is perf-optimized and is among the fastest MessagePack serialization libraries available for .NET.
  • Works great in your NativeAOT, trimmed, SignalR or ASP.NET Core MVC applications or Unity games.
  • Many C# analyzers to help you avoid common mistakes.
  • Great security for deserializing untrusted data.
  • Polymorphic deserialization lets you deserialize derived types.
  • True async and streaming deserialization for large or over-time sequences keeps your apps responsive and memory pressure low.
  • Deserialize just the fragment you require with intuitive LINQ expressions.
  • Preserve reference equality across serialization/deserialization (optional).
  • Forward compatible data retention allows you to deserialize and re-serialize data without dropping properties you didn't know about.
  • Structural equality checking and hashing for arbitrary types gives you deep by-value equality semantics without hand-authoring Equals and GetHashCode overrides.
  • No mutable statics ensures your code runs properly no matter what other code might run in the same process.
  • Only serialize properties with non-default values (optional).
  • Primitive msgpack reader and writer APIs for low-level scenarios.
  • Author custom converters for advanced scenarios.

Feature comparison

See how this library compares to other .NET MessagePack libraries.

In many cases, the ✅ or ❌ in the table below are hyperlinks to the relevant documentation or an issue you can vote up to request the feature.

Feature Nerdbank.MessagePack MessagePack-CSharp Serde.NET
Optimized for high performance ✅ ✅ ✅
Contractless data types ✅1 ✅ ❌
Attributed data types ✅ ✅ ✅
Polymorphic serialization ✅ ✅2 ✅
Duck-typed polymorphic serialization ✅ ❌ ❌
F# union type support ✅ ❌ ❌
Typeless serialization ✅ ✅ ❌
dynamic serialization ✅ ✅ ❌
Forward compatible data retention ✅ ❌ ❌
Property name transformations ✅ ❌ ❌
Skip serializing default values ✅ ❌ 🌗
Required and non-nullable property deserialization guaranteed ✅ ❌ ✅
Dynamically use maps or arrays for most compact format ✅ ❌ ❌
Surrogate types for automatic serialization of unserializable types ✅ ❌ ✅
Custom converters ✅ ✅ ✅
Stateful converters ✅ ❌ ❌
Deserialization callback ✅ ✅ ❌
MsgPack extensions ✅ ✅ ❌
LZ4 compression ❌ ✅ ❌
Trim-safe ✅ ❌ ✅
NativeAOT ready ✅ ❌3 ✅
Unity ✅4 ✅ ❔
Async ✅ ❌ ❌
Endless streaming deserialization ✅ ✅ ❌
Targeted partial deserialization ✅ ❌ ❌
Reference preservation ✅ ❌ ❌
Cyclical references ✅ ❌ ❌
JSON schema export ✅ ❌ ❌
Secure defaults ✅ ❌ ❌
Automatic hash collection deserialization in secure mode ✅ ✅ ❌
Automatic collision-resistant hash function for arbitrary types ✅ ❌ ❌
Rejection of data that defines multiple values for the same property ✅ ❌ ❌
Free of mutable statics ✅ ❌ ✅
Structural IEqualityComparer<T> for arbitrary types ✅ ❌ ❌

Security is a complex subject. Learn more about how to secure your deserializer.


  1. Nerdbank.MessagePack's approach is more likely to be correct by default and more flexible to fixing when it is not.↩

  2. MessagePack-CSharp is limited to derived types that can be attributed on the base type, whereas Nerdbank.MessagePack allows for dynamically identifying derived types at runtime.↩

  3. Although MessagePack-CSharp does not support .NET 8 flavor NativeAOT, it has long-supported Unity's il2cpp runtime, but it requires careful avoidance of dynamic features.↩

  4. See our unity doc for instructions.↩