# An introduction to Compact Binary Object Representation (CBOR) in .NET

DevFeed: [An introduction to Compact Binary Object Representation (CBOR) in .NET](<https://devfeed.tech/articles/an-introduction-to-compact-binary-object-representation-cbor-in-net-90927.md>)

Original publisher: [Read original article](<https://andrewlock.net/an-introduction-to-compact-binary-object-notation-in-dotnet/>)

Author: Andrew Lock

Published: 2026-10-20T10:00:00Z

Content type: article

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [Data serialization](<https://devfeed.tech/topics/data-serialization.md>), [.NET](<https://devfeed.tech/topics/net.md>), [Decoding](<https://devfeed.tech/topics/decoding.md>), [JSON](<https://devfeed.tech/topics/json.md>), [Encoding](<https://devfeed.tech/topics/encoding.md>), [hex value](<https://devfeed.tech/topics/hex-value.md>), [NuGet](<https://devfeed.tech/topics/nuget.md>), [system.text.json](<https://devfeed.tech/topics/system-text-json.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [apis](<https://devfeed.tech/tags/apis.md>), [asp-net-core](<https://devfeed.tech/tags/asp-net-core.md>), [base64](<https://devfeed.tech/tags/base64.md>), [data-protection](<https://devfeed.tech/tags/data-protection.md>), [data-serialization](<https://devfeed.tech/tags/data-serialization.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [json](<https://devfeed.tech/tags/json.md>), [net](<https://devfeed.tech/tags/net.md>), [net-10](<https://devfeed.tech/tags/net-10.md>), [net-11](<https://devfeed.tech/tags/net-11.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [net-framework](<https://devfeed.tech/tags/net-framework.md>), [nuget](<https://devfeed.tech/tags/nuget.md>), [nuget-package](<https://devfeed.tech/tags/nuget-package.md>)

## AI overview

CBOR offers a self-describing binary alternative to JSON, with native binary data, compact encodings for values such as small numbers, and support for indefinite-length collections that can help with streaming. Text payload sizes are roughly comparable to JSON, and actual savings depend on the data. The excerpt contrasts CBOR with Protobuf, which can be highly efficient but requires shared schemas, and MessagePack, which is similar but lacks CBOR's formal IETF standardization and streaming support as described here. In .NET, System.Formats.Cbor provides low-level CborWriter and CborReader APIs: callers write and read primitive values and manage structure themselves rather than automatically mapping objects. The examples cover encoding and decoding maps and arrays, selecting conformance modes such as canonical key ordering, and skipping unknown values for forward compatibility. The author suggests JSON remains suitable for most APIs and points to ASP.NET Core's use of CBOR for compact, application-specific cookie data.

## Source excerpt

In this post I introduce CBOR as a JSON alternative, and show how to use the System.Formats.Cbor NuGet package to read and write CBOR encoded data