Format Atlas

Compare

CBOR vs JSON

CBOR is a binary interchange format with a data model extending JSON, including values such as byte strings and tags. JSON is a human-readable text interchange format widely used by web APIs and configuration tools.

Which format should you choose?

Choose JSON for text that people edit or inspect and for compatibility with existing JSON APIs. Consider CBOR when a protocol needs compact binary data, byte strings, extended types, or deterministic encoding.

Good fit for CBOR

Structured data exchange on constrained devices and networks · Data representation in COSE and IoT protocols

  • Representing JSON-like data in a compact binary form
  • Using standard or application-defined tags to convey meaning

Good fit for JSON

Web APIs, configuration files, and data exchange

  • Transferring structured data

Basic information

FieldCBORJSON
Extension.cbor.json
MIME typeapplication/cborapplication/json
Common usesStructured data exchange on constrained devices and networks · Data representation in COSE and IoT protocolsWeb APIs, configuration files, and data exchange
How to openRead it with a CBOR library or decoder, then inspect its diagnostic notation or a JSON-like view. Check how values without direct JSON equivalents, such as tags and byte strings, are represented.Open it in a text editor, IDE, or JSON-aware viewer.
Export or convertWhen converting to JSON, byte strings and tagged values may need tool-specific representations because JSON has no direct equivalents. For signatures, hashes, or cache keys, follow the protocol's agreed encoding rules, such as deterministic encoding in RFC 8949.Applications or conversion tools can convert it to formats such as CSV.

Choose by use case

Representing JSON-like data in a compact binary form

Structured data exchange on constrained devices and networks · Data representation in COSE and IoT protocols

CBOR

Using standard or application-defined tags to convey meaning

Structured data exchange on constrained devices and networks · Data representation in COSE and IoT protocols

CBOR

Transferring structured data

Web APIs, configuration files, and data exchange

JSON

Key point 1

JSON is text represented as characters; CBOR items are binary bytes. CBOR directly supports integers, byte strings, and tags, while JSON usually needs conventions such as base64 strings for binary values.

More on the differences

Key point 2

RFC 8259 JSON defines objects, arrays, strings, numbers, booleans, and null without requiring an application schema. CBOR adds tagged values and a data model extending JSON.

More on the differences

More on the differences

Use JSON for inspectable text interfaces and broad tooling. Use CBOR for binary protocols that benefit from byte strings, tags, or deterministic encodings. Agree on tag meanings, numeric ranges, canonicalization, and library support at both ends.

  • CBOR's diagnostic notation is for debugging; actual interchange uses binary items. JSON interchange uses text.
  • Converting CBOR to JSON can lose tags, byte-string distinctions, integer representation, numeric precision, or deterministic-encoding properties.
  • Define how the receiver handles unknown tags, large integers, duplicate map keys, and values with no direct JSON equivalent; test both implementations with real payloads.

Frequently asked questions

Is CBOR just compressed JSON?

No. CBOR has its own binary data model and supports values such as byte strings and tags that JSON does not represent natively.

Learn more

References and specifications