A secure, fast, and feature-rich CBOR codec for Go, fully compliant with RFC 8949 and RFC 8742.
fxamacker/cbor is a comprehensive CBOR (Concise Binary Object Representation) encoding and decoding library for Go. It provides a robust, high-performance alternative to JSON and other binary formats, designed with a strong emphasis on security, speed, and standards compliance. The library is trusted by major organizations and used in critical systems.
Go developers working on systems that require secure, efficient binary data interchange, such as IoT, blockchain, authentication protocols (e.g., WebAuthn), and distributed systems. It is also suitable for projects needing standards-compliant CBOR handling with configurable security limits.
Developers choose fxamacker/cbor for its security-first design with configurable decoding limits and fast rejection of malformed data, high performance without using Go's unsafe package, and comprehensive standards compliance including CBOR, CBOR Sequences, and Extended Diagnostic Notation. Its API is familiar to users of encoding/json, and it offers struct tag optimizations to automatically reduce encoded size.
CBOR codec (RFC 8949, RFC 8742) with CBOR tags, Go struct tag options (toarray, keyasint, omitempty, omitzero), float64/32/16, big.Int, and fuzz tested.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Configurable decoding limits and fast rejection of malformed data defend against adversarial inputs, with benchmarks showing it rejects malicious CBOR in 47 ns/op compared to millions for other libraries.
Optimized for speed and memory efficiency without relying on Go's unsafe package, making it safe for concurrent use in production systems.
Full support for CBOR RFC 8949, CBOR Sequences RFC 8742, and Extended Diagnostic Notation, ensuring interoperability with other CBOR implementations.
Tags like toarray, keyasint, omitempty, and omitzero automatically reduce encoded size, as shown where a nested struct encodes to 1 byte versus 18 bytes for JSON.
API mirrors encoding/json with functions like Marshal and Unmarshal, reducing the learning curve for Go developers.
Advanced features require understanding DecOptions and EncOptions, and setting up custom modes or tag sets can be non-trivial, especially for users new to CBOR.
Effective use demands familiarity with CBOR standards, tags, and struct tags, which may be a barrier compared to ubiquitous formats like JSON.
TinyGo compatibility is in a beta branch, not fully fuzzed, and has reduced default limits, making it risky for critical TinyGo applications.
As a CBOR library, it has a smaller community and tooling than JSON, which can affect finding resources or third-party integrations for niche use cases.